Due by 11:59PM EDT on Wednesday, April 19, 2017
15 points
Please provide written responses to the following questions. Each response should be at least 5-7 sentences in length. Each question is worth 5 points.
35 points
Complete the following programming assigment and submit your code using the GitHub repository that you will have created for this assignment. This assignment must be completed in the C programming language (you can choose to use C89/C90/ANSI-C, C99, or C11 as you see fit).
In this assignment, you will be augmenting your shell from Homework 1 with a few new features:
To aid in your development of this new version of the shell, I've provided some useful utility functions. You can find the code to these functions here and a header file for them here. In particular, the unescape function in there should be quite useful (i.e, this will do the hard work of the last requirement up there). You do not have to use these source files if you don't want to, but it would be kinda silly not to. If you choose to not use them, you must still unescape strings as specified above in the same manner as my unescape function. It will be up to you to ensure that your implementation is functionally equivalent if you do not use mine.
As a hint, many (but not all) of the commands that you are to implement boil down to parsing out arguments, checking for error conditions, and running one function from the C library. I'm pretty deliberate about how I name things, so you might use that as a good starting point for searching in the Open Group Base Definitions.
Your shell program is not allowed to use any external libraries other than the system's C library and the files provided in this assignment. Do not try to use libraries like Readline. You will lose points for using external libraries to implement shell functionality! In addition, the C library functions specifically outlawed in Homework 1 are still outlawed in this assignment, as is using another shell to do the work of parsing arguments and running commands. Please refer back to Homework 1 if you have any questions on this.
Here is an example shell session demonstrating some of the new functionality in this assignment:
$ getenv HOME /Users/lj $ getenv PWD /Users/lj/421-sp2017/shell $ cd .. $ getenv PWD /Users/lj/421-sp2017 $ ls -l total 24 drwxr-xr-x 14 lj staff 476 Mar 3 16:44 shell -rwxr-xr-x 1 lj staff 9420 Feb 18 11:42 simple_shell $ cd shell $ /bin/ls -la total 184 drwxr-xr-x 14 lj staff 476 Mar 3 16:44 . drwxr-xr-x 5 lj staff 170 Feb 19 14:59 .. drwxr-xr-x 13 lj staff 442 Feb 19 12:53 .git -rw-r--r-- 1 lj staff 304 Mar 3 11:02 Makefile -rw-r--r-- 1 lj staff 5103 Mar 3 16:44 builtin.c -rw-r--r-- 1 lj staff 228 Mar 3 10:58 builtin.h -rw-r--r-- 1 lj staff 10808 Mar 3 16:44 builtin.o -rwxr-xr-x 1 lj staff 20048 Mar 3 16:44 simple_shell -rw-r--r-- 1 lj staff 2674 Mar 3 16:27 simple_shell.c -rw-r--r-- 1 lj staff 8272 Mar 3 16:27 simple_shell.o -rw-r--r-- 1 lj staff 3568 Feb 23 11:34 test.o -rw-r--r-- 1 lj staff 7558 Mar 3 16:10 utils.c -rw-r--r-- 1 lj staff 2330 Mar 3 16:19 utils.h -rw-r--r-- 1 lj staff 9368 Mar 3 16:10 utils.o $ setenv MESSAGE="Hello, world" $ getenv MESSAGE Hello, world $ setenv MESSAGE="Hello, 'Lawrence'" $ getenv MESSAGE Hello, 'Lawrence' $ setenv MESSAGE=Hello,\ \"Lawrence\".\ How" are you today?" $ getenv MESSAGE Hello, "Lawrence". How are you today? $ chdir / $ getenv PWD / $ chdir $ getenv PWD /Users/lj $ echo \x48\151\x20\157\165\164\040\x74\x68\x65\x72\x65\041 Hi out there! $ echo Goodbye, \'World\'\a Goodbye, 'World' $ /bin/echo \x48\151\x20\157\165\164\040\x74\x68\x65\x72\x65\041 Hi out there! $ exit
When submitting your shell program, please be sure to include the source code of the shell program (in one or more C source code files), as well as a Makefile that can be used to build the shell. Your shell must be able to be built and run on a VM as has been set up for this course in your projects. If you use my utility functions, make sure to include those files as well.
As this should be an extension of your earlier homework 1 shell, you should be using the same directory and git repository for it. To submit your code, you should do the following:
git add your_updated_and_added_files_go_here git commit git push -u origin master git tag hw2 git push origin --tags
Last modified