Assignment 8 - A Simple Command Shell: Part 2
Due: Tuesday, November 14, at 10:00pm
Upload solutions via Moodle as either:
shell208.tar
shell208.c
See Part 1 for more details on what you should submit.
Goals
This assignment is designed to help you with the following:
- extending a prior project
- learning how to use pipes for inter-process communication
- learning how to handle signals
Rubric
This assignment is worth a total of 15 points. They are allocated as follows:
// General
1 - author name (and collaborators) in a comment at the top of any `.c` files
3 - code quality
ε - come up with a clever-yet-friendly name for your shell and modify your prompt
accordingly
// Regression Testing
3 - everything from Part 1 still works
// New features
2 - support redirection of stdin via <
2 - support "cmd1 | cmd2", basic version
2 - support "cmd1 | cmd2", full version
1 - exit
1 - handle SIGINT signals
1 - handle multi-pipe pipelines
You are expected to follow the same submission instructions as last time; if your shell208.c
or shell208.tar
file cannot be used without modification, you will not receive any of the “code quality” credit for this assignment.
Notes on the rubric:
-
The basic version of piping should enable piping cmd1’s
stdout
to cmd2’sstdin
, assuming no arguments for either. For the full version, you should support command-line arguments for both commands. -
When handling
SIGINT
signals (sent to the parent process, i.e., your shell process), your program should respond by printing^C
tostderr
and printing the prompt again; to exit the shell, the user should typeexit
. -
For multi-pipe pipelines, an example command-line entry is
ls -lah | grep ".txt" | wc -l
. You may impost a fied limit of 7|
s if that helps.
You’ll note that this assignment is graded out of 15 points, but there are 16+ε available. You are welcome to implement all of the above functionality, but your score will be capped at 15 points.
Your assignment
For this assignment, you will complete your simple command shell, named shell208
. For Part 2 of this project (i.e., this week’s assignment), you will implement the styles of operation listed in the rubric above.
For Part 2, your shell should additionally be able to handle:
- redirection of standard input (
stdin
, via<
) from a file, - piping commands via
|
, and - capturing
SIGINT
signals.
You should also still be able to handle the following requirements from Part 1:
- single-word commands (e.g.,
ls
,pwd
,help
), - commands with command-line arguments (e.g.,
ls -l
,echo dog
), and - redirection of standard output (
stdout
, via>
) to a file.
For example, each of the following should work as they do in bash
on mantis
:
shell208$ help
shell208$ ls
shell208$ ls -l mysubdirectory
shell208$ ls -l > listing.txt
shell208$ wc < myfile.txt
shell208$ ls -lah | wc
shell208$ ls -lah | grep .txt | wc -l
shell208$ ^C /* user pressed ctrl-c */
shell208$
shell208$ exit
Submitting your work
You should submit your program via Moodle as described in Part 1.
Have fun!