#deviation fromnominal requirements
Unix shell that takes user input and executes a subset of
a typical shell's commands. The code supports built-ins cd, exit and ioacct. It also supports forking, i/o redirects, pipes, and
background processing.
- cd src
- make (or "make -s" to quiet the make process)
- ./shell
- exit
- Sean and Edward divided the entire project equally except that Edward handled the memory leaks using Valgrind and Sean did the report. Otherwise, the team members met and coded the entire project together (with a few small, not notable, exceptions).
-
makefile Compiles the program
-
shell.c Main loop which displays the prompt, handles user input and user commands. printPrompt() displays the prompt while exitShell() is called at exit.
-
handleInput.h, handleInput.c Stores the user's input into an array of C strings which we call "tokens." Tracks the number of tokens.
-
handleCommand.h, handleCommand.c Main resource for executing built-ins and executable system binaries such as "ls" or "grep." Receives the user's input in the form of a list of tokens. Executes the commands. Also performs the ioacct command which gets the total bytes read and written by a process.
-
posixVars.h Many Linux systems define the sizes for host name, path name, etc. in a file called posix1_lim.h. If at all possible, we wanted to use these sizes in our shell. However, in the case that these sizes are not defined, we needed to define them ourselves in the posixVars.h header file. We also defined a few global variables, such as the current working directory and previous working directory here as well.
-
tokenize.h, tokenize.c Receives the $PATH environment variable and tokenizes it based upon the ":" delimiter into an array of C strings. We check this array for the location of an executable in handleCommand.c
-
program.h, program.c Defines a program and instantiates it witl default values upon creation. Used by handleCommand.c when the user input is not a built-in but rather an executable.
-
executeCommand.h, executeCommand.c Execute command executes the binary. If the binary is not a direct path, it calls getFinalPath() to determine where the binary resides.
-
commandList.h, commandList.c Defines a list of programs to be executed as an entire command. CommandList.c parses the TokenList into programs.