Project 1: Getting out of your shell

posted Nov 21, 2016, 6:42 AM by JonAlf Dyrland-Weaver   [ updated Dec 1, 2016, 8:48 AM ]
Project Due: Friday 12/2 11pm

You (and up to 2 partners) are to write a shell. The shell should implement as many of these features as possible. The first being the most basic up to the last which is the most complex.
  1. Read a line at a time, parse the line to separate the command from its arguments. It should then fork and exec the command. The parent process should wait until the exec'd program exits and then it should read the next command.
    1. Note: exit and cd cannot be run through a forked child process, you will have to implement these commands on your own.
  2. Read and separate multiple commands on one line with ;. That is, the line ls -l ; echo hello should first run the command ls -l and thenecho hello. I would recommend parsing the line on ; and then calling whatever you wrote for part 1 on each command. 
  3. Implement simple redirection using > (redirecting stdout) and < (redirecting stdin). - This will be explained in class on Tuesday, 11/22
  4. Implement simple pipes, that is: ls | wc would run ls and use the output from ls as the input for wc. - This will be explained in class on Tuesday, 11/22. 
All of these commands work in bash, so use it to check out the functionality of each feature if you are unclear about anything.

Specific requirements
  1. Every function you write must have a function header describing the arguments, return value and what the function does.
  2. You should have a readme file with the following:
    1. A description of what features your shell implements
    2. A description of what features you attempted to implement but were unsuccessful
    3. Any bugs or things you want me to know about your program
    4. A copy of every function header
    5. An example of the readme file can be downloaded from this page (see "Attachments" below)
  3. This project should use separate C files as necessary.
  4. The project should be built using make and a makefile, I will only compile by using make. 
Project hints (If you're having trouble)
  1. To make your life easier, you could require that all items on the command line are to be separated by a single space.
  2. When parsing the line, it might help to count the number of tokens (individual pieces), before using strsep (remember the strchr function?)
  3. You can restrict the locations and ordering of > and <. 
  4. You can limit piping (|) to a single pipe. 
If you would like to implement other features after getting these ones down, please do. Look at what bash does and see what else you can implement!

Github links (one directory per group):
JonAlf Dyrland-Weaver,
Nov 21, 2016, 6:42 AM