Machine Problem IV, due Mar. 26
Begin with the version of mush.shar distributed to the class with this assignment. It incorporates some small changes to the solution distributed for MP3.
a) With the built-in shells, shell-scripts are executable files that begin with a line that looks like this:
Modify mush so that it can execute mush shell scripts. For the following example, suppose your HawkID is hawkid. This means that your home directory is /space/hawkid. Suppose that you are developing mush in a subsidiary directory called mush. This means that it's absolute path name is /space/hawkid/mush. When you run make in the mush development directory, it creates an executable file called mush. The absolute path name of that file is /space/hawkid/mush/mush. Given this, you should be able to write mush shell scripts that begin like this:
To do this, you will need to modify the main program of mush so that it conforms to the expectations of the execve() kernel call. The key expectations are documented in the writeup on interpreter scripts in the man page for execve().
b) If you test the standard Unix shells, you'll find that when you run a shell script, all of the command line arguments you pass are passed to the script. If you launch your script as follows:
./myscript has arguments
You will find that, inside the script, $0 is replaced with ./myscript, $1 is replaced with has, and $2 is replaced with arguments. to the called program. (See Homework 3, problem 1)
Modify the main program for mush so that you can pass command line arguments to mush scripts. The easiest way to do this is to go through the command line arguments and add them all to the environment using setenv().
All of your code must conform, as much as is possible, to the manual of style:
Your solution must be in a file named main.c (all lower case). Submit your solution using the coursework submission tools documented at:
In short, you will type the shell command submit, with no arguments, and when it prompts for a file name, you will type main.c. and then an extra carriage return to indicate that there is only one file in your submission. When it prompts for a course, type CS3620 and when it prompts for an assignment directory, enter mp4.
Note, file names on Unix/Linux systems are case sensitive! That includes the course name. If you type cs3620, it will not work. If you type CS:3620, it will not work.