This document describes the design patterns and components used to create a C-shell. The shell uses a reactor pattern to run a main loop that takes user input and sends it to a parser. The parser splits the input into commands and passes them to a job factory to create processes using the builder pattern. Jobs set up piping between processes as needed. Each process is forked and executed in its own process object. The shell itself follows the singleton pattern to provide global access to variables. Basic commands like ls, cd, and help are included, along with notes on challenges in implementing piping and parsing special characters.
3. Shell Reactor
• main function
• while loop, terminates when
user enters “exit”
• Sends user input command to
parser
4. ShellParser
• Splits up each word in the
passed string based off of “ “
character.
• Pushes into a vector of strings.
• Also controls things such
whether process will run in
background, piping, output.
• Creates a new job from
command.
• T
5. Job
• Factory
• makeJob() makes a new
process from the commands
• launch() launches the process
in job once they are made
• Job sets up piping for multiple
process
6. Process
• With each process, a new
process object is created.
• The process is then forked
and exec’ed
• Output is printed to terminal
7. Shell
• Singleton Pattern- only one
instance
• Holds a lot of the variables we
need to keep global such as
our command vector and
terminal process id
• Mostly consists of accessor
methods
8. Shell Commands
• ls - lists all files in the directory
• cd - changes directory
• dirs - outputs current directory
path
• exec - execs a process, then
quits
• wait - waits for a process to
finish based off of its pid
• help - displays a small help
menu with valid commands
9. Some Challenges
• Piping- it took some time to figure out job
management that allowed us to pipe.
• Parsing Special Characters- size_t overflow due
to npos being values as “-1”
• Testing- Finding good use cases to test each
feature as it was implemented.