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
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:
A prompt of the form “>” will appear and then you can type commands like:
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:
and the solution for part 1 can be run by typing:
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:
and the solution for part 2 can be run by typing:
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:
and the solution for part 3 can be run by typing:
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 Choose Us
We value our clients. For this reason, we ensure that each paper is written carefully as per the instructions provided by the client. Our editing team also checks all the papers to ensure that they have been completed as per the expectations.
Professional Academic Writers
Over the years, our Acme Homework has managed to secure the most qualified, reliable and experienced team of writers. The company has also ensured continued training and development of the team members to ensure that it keep up with the rising Academic Trends.
Our prices are fairly priced in such a way that ensures affordability. Additionally, you can get a free price quotation by clicking on the "Place Order" button.
We pay strict attention on deadlines. For this reason, we ensure that all papers are submitted earlier, even before the deadline indicated by the customer. For this reason, the client can go through the work and review everything.
At Buy An Essay, all papers are plagiarism-free as they are written from scratch. We have taken strict measures to ensure that there is no similarity on all papers and that citations are included as per the standards set.
Customer Support 24/7
Our support team is readily available to provide any guidance/help on our platform at any time of the day/night. Feel free to contact us via the Chat window or support email: email@example.com.
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.
Buy An Essay has stood as the world’s leading custom essay writing services providers. Once you enter all the details in the order form under the place order button, the rest is up to us.
At Buy An Essay, we prioritize on all aspects that bring about a good grade such as impeccable grammar, proper structure, zero-plagiarism and conformance to guidelines. Our experienced team of writers will help you completed your essays and other assignments.
Admission and Business Papers
Be assured that you’ll definitely get accepted to the Master’s level program at any university once you enter all the details in the order form. We won’t leave you here; we will also help you secure a good position in your aspired workplace by creating an outstanding resume or portfolio once you place an order.
Editing and Proofreading
Our skilled editing and writing team will help you restructure you paper, paraphrase, correct grammar and replace plagiarized sections on your paper just on time. The service is geared toward eliminating any mistakes and rather enhancing better quality.
We have writers in almost all fields including the most technical fields. You don’t have to worry about the complexity of your paper. Simply enter as much details as possible in the place order section.