Assignment 3 – Improving a Shell
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
The contents of the file are C sources that implement a simple shell. The contents are:
To compile these sources run:
gcc -o smsh1 smsh1.c splitline.c execute.c
To run the shell type:
./smsh1
A 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.c
The 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 | wc
at the prompt you get:
ls: wc: No such file or directory ls: |: No such file or directory
Write 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 part1
and the solution for part 1 can be run by typing:
./smsh2
Note, 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 Marks)
Your version of smsh2 currently doesn’t support redirection of output and input of commands such as:
ls > tmp.txt cat < tmp.txt | wc > out.txt
Copy your smsh2.c program from part 1 to smsh3.c so that it can handle redirection of standard input and standard output (don’t worry about stderr) using the “>” and “<” symbols. Again, you are free to add and modify files as required to accomplish this task (without affecting the ability of your code to correctly execute the behaviour required for part 1). You must add a Makefile to your submission so that you can compile all the files for part 2 by typing:
make part2
and the solution for part 2 can be run by typing:
./smsh3
Note, your program must still cater for all the behaviours that were correct in the original version of smsh2.
Part 3 – Adding Globbing – (20 marks)
Your version of smsh3 currently doesn’t support wildcards in command lines such as:
ls *.c cat *.h
Copy your smsh3.c program from part 2 to smsh4.c so that it can handle wilcard symbols in the command line. This expansion of wildcards is called globbing.
Note, you can use the glob system call (type “man -s3 glob” to find out more) that helps you to expand the wildcards to a list of actual filenames.
Again, you are free to add and modify files as required to accomplish this task (without affecting the ability of your code to correctly execute the behaviour required for previous parts). You must add a Makefile to your submission so that you can compile all the files for part3 by typing:
make part3
and the solution for part 3 can be run by typing:
./smsh4
Note, your program must still cater for all the behaviours that were correct in the original version of smsh3.
Detailed Submission Instructions
This assignment is basically like every other assignment you’ve ever done in CS… but just as a reminder:
The handin key for this exercise is: prac3. The following SVN commands will enable you to make a repository for this assignment. Please note the following:
Use the Unix “cd” command to change to the place where you want your exercise directory to be stored, then type these commands:
svn mkdir –parents -m “spc prac3 start” https://versioncontrol.adelaide.edu.au/svn/a1aaaaaa/2018/s1/spc/prac3
(creates this directory in your svn tree) svn co https://version-control.adelaide.edu.au/svn/a1aaaaaa/2018/s1/spc/prac3 .
(checks out a working copy in your directory) You can now begin work.
You can add a file to the repository by typing the commands:
svn add NAME-OF-FILE svn commit -m “REASON-FOR-THE-COMMIT”
where “reason-for-the-commit” should be some brief text that explains why you changed the code since the last commit. Note that you only need to add a file once — after that, SVN will “know” it is in the repository. You are now ready to commence working on the exercise.
The files you handin must include:
You do not have to include any of the add_one.c files or their variants… that you used for testing we will supply those.
Make sure you commit your files frequently, in case you have an accident. The University’s SVN repository is very reliable, and is backed up regularly — your computer probably is not… Regular submission is also a good defence against plagiarism by others, since the submissions are dated. We will test the behaviour of your scripts using an automated tester. The tester is thorough, and will find places where your scripts do not work correctly. If it finds an error, it will offer a (vaguish) hint. To encourage you to test your own work, the tester will not be fully available in the first few days before the exercise deadline.
The websubmission system will award up to 6 marks automatically. We will manually check the code for style and commenting and for code associated with the optional bonus exercise. Note that we reserve the right to deduct marks if your code does anything egregious or games the system to obtain marks.
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
Essays
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admissions
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Reviews
Editing Support
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
Reviews
Revision Support
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.