Teaching‎ > ‎CS 4520: Operating Systems‎ > ‎Projects‎ > ‎

Shell 1

Write a simple shell in a systems programming language.

Choice of Language

What is a systems programming language?  For our purposes, any language with the POSIX fork(), exec(), and pipe() functions will work.  These functions are only implemented in C, but many languages have straightforward bindings to them.  I recommend one of the following languages:
  • C (obviously)
  • C++ (tho you won't need it)
  • Go (if you are brave)
  • Python (if you are lazy)
  • Ruby (if you are crazy)
If you want to use another language, please ask me first.  In reality, most of your program will involve using the same C functions as everyone else, so your favorite language won't really help you much.


Your shell will be a program that loops until the user types "exit" or hits Ctrl-D (End Of File).  Each line of input will be interpreted as a command in the form:

<prograname> [arg1 arg2...]

When the user enters a command, you are to run the specified program using the POSIX exec*() family of functions, passing any specified arguments to the program.  After the program terminates, your shell should continue accepting input.

Your shell must also accept reading from file input.  To test your program, create a simple shell script and run it using your shell:

$ ./mysh script.mysh

  -- OR --

$ ./mysh < script.mysh


Looking Ahead

Make sure to design your code well, because we will be adding many features to the shell over the next few weeks.  If you finish these requirements early, I recommend you begin adding features to make your shell more shell-like.