The University of Tennessee at Martin
Make your shell show how long each command ran. Simply get the time (in long seconds) before and after the wait command, and then print “That command took ### seconds to run,” after a command has run. IE, when the wait finishes. For extra credit, have a parameter or command to turn the timer on or off.
Add Environment Variables and a Path function to your mini shell. Your program should read the environment variables (including PATH) from the third argument of main. The code envs.c in my directory (~/bobb/c) shows an example of reading the path variable and parsing it into separate parts. Then when a user types a command in your mini shell, your shell should check to see if the command is in each of the path directories listed in the PATH variable, and run the first one it finds.
This is what the PATH variable looks like on mars:
Notice that it is made up of several directories separated by colons. Your program should search the directories left to right. IE, with the path shown above, your program should look in /usr/bin first and /usr/local/bin/java/bin next to last.
Also, the program should pass the Environment Variables from main() to the child program through the Exec call. After doing this, you should be able to run your shell from your shell.
Make your shell respond to Control-C gracefully. Add signal-handling code to make your program exit out of its loop and say “Goodbye” when a user presses Control-C. Make it act the same as if the user had typed exit or quit. What happens if the user presses Control-C while the child program is running? Does the child quit or ignore the signal? You should probably have the child quite, but experiment to see what you can do.
Make your shell redirect a program’s output to a file if a greater-than (>) is used. If the user types a command followed by a greater-than sign (>) and a file, make your shell redirect the programs output to the file given. IE: ls –la > file.txt should make the ls command output to the file.txt file given. We will have to talk about code to make programs redirect input and output. The calls to do this will be open on the new file, close(1) and then dup.
For a grade of A, demonstrate each part of the program on or before the due date
For extra points: demonstrate the program early; or add something else interesting to your minishell.