This project focus on creating a simple shell, the ”Wimpy SHell”, which will use a command line interface, and will support foreground (interactive) processing, background (batch) processing, redirection, pipes, and job control.
A ”foreground job” is a command of the form ARG0ARG1…ARGn , and a foreground process is created with following procedures:
For examples:
cp file1 file2
cp -R dir1 dir2
rm -f -R dir1 dir2 file1 file2
xterm
A background job, a command of the form ARG0ARG1…ARGn&, acts like a foreground job, except the shell does not wait for the process to terminate, but let the process run at the background. Thus, a background job should be executed as follows:
Unlike foreground jobs, the shell must keep track of background job
information using an appropriate data structure. This allows the shell to display
the status of each background job. Each background job should be assigned a
”job number”, to be used as an index when displaying the information about the
job. A background job’s number should remain fixed for its life. The
job numbers should be incremented for each new background job, and
when no background jobs exist, the job number should reset to 1. For
example:
Running:
[1] cp file1 file2
[2] cp -R dir1 dir2
[4] xterm
Finished:
[3] rm -f -R dir1 dir2 file1 file2
If the xterm is then closed, the next status report might be:
Running:
[1] cp file1 file2
[2] cp -R dir1 dir2
Finished:
[4] xterm
Both background and foreground jobs should be able to redirect standard input
and output using < and >, respectively, where > outputs to the designated
file, and < reads data from the specified file. For example, ls -a -l -F >
file1
ls -a -l -F > file2 &
should send the output of ls to file1 and file2,
cat -n < file1
should read from file1 instead of standard input, and
cat < file1 > file2
cat > file3 < file1
should read from file1 and write to file2 and file3.
Here is the list of build-in command:
A command pipeline of the form job1|job2|…|jobn , where each job is a sequence
of arguments (like a foreground job). Examples:
cat -n file | less
ls -alF | sort -n -r +4 | head -5
cat -n file1.cc file2.cc | grep #include | sed -e s/include/exclude/ | head
-5
yes + | head -15 | cat -n | sed s/10/10x/ | tr -d \ n | tr x \ n | head -1 |
bc