Machine Problem 2, due Feb. 23

Part of the homework for 22C:112, Spring 2009
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Background: The C source file Contains a working command shell that should work under most Unix systems. Unfortunately, its slate of features commands is rather slim.

Proper Unix shells allow input/output redirection. So, where the command cat myfile will output the contents of myfile to the screen, cat myfile > outfile will create or overwrite the file outfile and then copy the contents of myfile to outfile.

Similarly where the tcsh shell command launches a new shell that reads commands from standard input, tcsh < infile launches the new shell to read commands from infile.

If you use the man tcsh command, you can read about the official syntax for input or output redirection.

Assignment: Implement input/output redirection. Be simple minded about parsing! You may require spaces around the > and < characters if this simplifies your parsing.

You will have to deal with the semantics of the Unix kernel calls for opening and closing files. Use man 2 open, and man 2 close for documentation.

Your code should operate reasonably for malformed input, and it should conform to the C style guidelines for the class, and you should submit your source file using ICON.

Grading will focus on style as much as function, so working code will not earn more than half credit unless it is clear and readable, and clean code will earn some credit even if not functional.