Name: Ziting Shen & Rachel Xu Date: 05/09/2016 Exercise: Final Project
-
Introduction This project is an imitation of the Unix shell program with our own customization. As a command-line interpreter, the Unix shell interprets the commands enter by the user and executes them. For this project, we implemented about 30 functionalities in C/C++, descriptions and examples of which are listed below.
-
Structure and Implementation of the Program Here's a list of files (including header files) included in this program:
joblist.cpp (Ziting) rachel.cpp (Rachel) rachel.h (Rachel) shell.cpp (Ziting & Rachel) sleeper.cpp (Ziting) tester.cpp (Rachel) ziting.cpp (Ziting) ziting.h (Ziting)
shell.cpp is the main program
joblist.cpp implements the structs joblist_t and job_t for job handling
rachel.cpp/rachel.h implements the following functionalities:
-
pwd (pwd) Prints out the path of current working directory.
-
grep/grep_regex (grep) Searches for lines of text that match a regular expression, and outputs only the matching lines by default.
-
truncateComments (#) Processes the command line input and removes the parts following # (comments).
-
changeDirectory (cd) Changes working directory to a directory specified by a pathname.
-
redirect (redirection ">" & "<") Redirects the input/output of a command from/to a file.
-
piper (pipeline "|") Connects two or more programs together so that the output from one program becomes the input of next program.
sleeper.cpp uses the sleep() function for shell program testing
tester.cpp implements a tester program for command line parser
ziting.cpp/ziting.h implements the following functionlities:
-
jobs (jobs) Prints out all running and suspended jobs.
-
SIGINT (ctrl-c) Sends a signal to shell when the user enters ctrl-c at the prompt.
-
SIGTSTP (ctrl-z) Sends a signal to shell when the user enters ctrl-z at the prompt.
-
historyPrint/saveHistory (history) Saves and prints out command line history.
-
do_fgbg (fg/bg) Sends a suspended job to background or sends a background/suspended job to foreground.
-
kill (kill) Sends signals to running processes to request termination of the process.
-
setvariable/unsetvariable (set/unset) Assigns a value to or removes a local variable.
-
alias/unalias (alias/unalias) Assigns a value to an alias or removes an alias.
- Compile and Run
Compile with "make" command and run "./shell.cpp". Enter any command at the "shell>" prompt.
- Known Bugs & Deficiencies
- The command "vim" causes a signal 22 and does not start vim.
- The command "./shell" also causes a signal 22.
- Quotes are treated as part of string.
- Wildcard expansion is not implemented.
- Grep does not support multiple files or multiple regular expressions.
- Man page cannot be opened from our shell.