Project 1
A Simple Shell
In this assignment, you will implement a simple shell.
- Assignment Specification
- supplement: lex.l
- supplement: myshell.c
- supplement: Makefile.partial
- supplement: proj1tester.tar.gz
- supplement: forktest.c
- supplement: pipetest.c
NOTES
- The due date for this assignment has been changed to Jan 16th, 2004.
- A good reference to check out is Chapter 7 of The UNIX Programming Environment, by Kernighan and Pike. You can also find slides and other tutorials on the web that gloss over the material.
- You can also read the documentation for system calls in section 2 of the UNIX manual. On the CATS machines, you can do this by running "man -s 2 fork", for example.
- Another book that you can probably find at Border's is Advanced Programming in the UNIX Environment, by W. Richard Stevens. I have only seen this book on the web, but I am familiar with the author and think it likely that this would be a good book.
- The projects page describes submitting compressed tar files. There is a new supplement that you can download and add to your existing Makefile, which includes a target for building the appropriate archive. Once added, you can run "make tar" from your command line to build the tar file to submit.
- 11-Jan: some of the files I will use for testing are now available. Testing is your responsibility, but these files will give you an idea of how you will be graded.
- 16-Jan: Here are some details that
weren't in the assignment:
- The prompt for your shell should be "myshell: ".
- Right before your shell exits, it must print out the string "Good bye.\n" Don't forget that users can exit your shell by typing ctrl-D!
- If the command a user enters doesn't exist,
you need to print a message to that effect.
It should be "<cmd>: Command not found.\n"
For instance, if the user enters
bogus cmd and args
your shell must respond withbogus: Command not found.
- Section 3.2 of the assignment says that you need to check the return code of the command and print a message if it's abnormal. The message you should print is: "Abnormal return code: %d\n". The return code refered to is the argument that was passed to exit() by the child.
- The exit command should not have any arguments. In that case, you should print an error message: "exit: No arguments allowed.\n"
- 13-Jan: The forktest.c program shows a simple example of how you write code that forks and shows different behavior for the parent and child processes.
- 15-Jan: The proj1tester has been updated to fix two bugs in the tests.
- 15-Jan: Added pipetest.c as an example of how to use pipes in children processes.
- 16-Jan: Several people have asked about using alternative calls, if they are easier to use, such as dup2(), waitpid(), and freopen(). Try not to; the assignment was pretty specific about what to use, and it's important to follow specifications when they are given. You will likely lose some small number of points if you do use something different.
Last updated 19 Jan 2004 by Bo Adler