CSC 271

Homework 5
assigned 4 Dec, due 10 Dec

Extend your previous shell (homework 4) with I/O redirection (at least) and some other nifty features.

Minimum requirements

The shell should print a prompt, allow the user to type any ordinary Unix command, possibly with arguments, run that command until it finishes, print another prompt, run another command, and so on until the user types the special command "exit". You must handle I/O redirection: if the user types a command followed by "> filename" or "< filename", you should redefine stdout or stdin (respectively) to be the specified file before running the command.

Some of you used the "system" function for homework 4, which is OK. But I'd like to make sure you know how to use "fork", "exec", and "wait", and how to pick apart a command line into words. So for homework 5, please don't use the "system" function.

Picking apart a command line into words, recognizing punctuation marks like ">" and "<", and recognizing special commands like "exit" and "cd" is much easier with the help of lex, so I recommend writing all or much of your shell as a lex program. I/O redirection, pipes, semicolons, environment variable expansion (e.g. "$TERM"), file completion, wildcard filenames, or the "~" directory specifier.

Other features to add

If you didn't get the variable shell-prompt, the "setenv" command, the "cd" command, or the "exit" command to work properly in homework 4, fix them.

Other things to do for extra credit

Note: The last three of these require treating a "command" as a unit within a line, rather than as synonymous with a line. It may be easier to pick these things apart by using yacc or bison in addition to lex or flex.
Last modified: Wed Dec 4 12:51:49 EST 1996
Stephen Bloch /