Assignment 3 – Improving a Shell
Due date 11:59pm – Sunday Week 10.
In this assignment you shall take an existing implementation of a shell program and add some small improvements to it.
Preparation – Downloading, Compiling and Testing a simple Shell Implementation
Download and un-compress the following file:
shell.tgz download
The contents of the file are C sources that implement a simple shell. The contents
are:
smsh.c – an implementation of a very simple shell program
smsh.h – a header file with function prototypes
execute.c – a set of helper functions for running processes within the program
splitline.c – some text processing utilities
To compile these sources run:
gcc -o smsh1 smsh1.c splitline.c execute.cTo run the shell type:
./smsh1A prompt of the form “>” will appear and then you can type commands like:
> ls
execute.c shell.tgz smsh.h smsh1 smsh1.c splitline.c
> wc execute.c
37 113 725 execute.cThe shell is terminated by typing the Control-D key (which signals end of input).
In this assignment you shall add functionality to this shell command. Each part builds
upon the last.
Part 1 – Adding the ability to pipe commands to your shell
(30 marks)
At the moment smsh1 doesn’t support piping of commands. So, for example, if you
type:
ls | wcat the prompt you get:
ls: wc: No such file or directory
ls: |: No such file or directoryWrite a new program called smsh2.c that is based on smsh1.c which performs all of
the shell operations of smsh1.c but also allows commands to be piped as above so
that if you type:
ls | wc
You get output like:
6 6 53
instead. You are free to add and modify files as required to accomplish this task. You
must add a Makefile to your submission so that you can compile all the files for part1
by typing:
make part1and the solution for part 1 can be run by typing:
./smsh2Note, your program must still cater for all the behaviours that were correct in the
original version of smsh1. You may find the lectures on piping useful in completing
this part.
Part 2 – Redirecton of stdin and stdout (30 Mar