Project 2: File Redirection in the Shell
Due Monday, April 25, by 9:00 AM
In class, we've been writing a shell, but so far have avoided adding file redirection! This prevents use of commands like this:
grep tiger * 2> /dev/null
date >> date_log
bc < math_problem
For the class shell, add support for 5 redirection operators:
> >> 2> 2>> <
The run_command function in the shell takes parameters for input and output sources, so file descriptors can be passed to this function. Remember when opening a file to close it after calling run_command, or it will stay open. I suggest starting by adding parsing to find redirection operators, and then adding file descriptor handling afterward.
For the append vs. replace, you will have to specify different file opening flags (read about O_APPEND in the manual page for open(2) ). The behaviour should be the same as it is in bash (the default shell on isoptera).
Upload your completed project like project 1.