CS631 -- Advanced Programming in the UNIX Environment - Final Assignment

Write a simple shell

Summary

In this assignment you will write a simple shell. In doing so, you will apply most of the lessons we learned in this class and gain a better understanding of how complex something as simple as a command-line interpreter can become as you compare the features available in a POSIX compliant shell with your own simple shell.

Problem assignment

Write a simple command-line interpreter as described in this manual page. As usual, your homework submission / program will:

  • follow the general homework guidelines
  • be written in plain C
  • consist of multiple files
  • include a Makefile
  • follow the principle of least surprise for the user
  • not generate any output other than that which was requested
  • generate meaningful error messages (to stderr) when appropriate
  • not add additional features that are not in the specification (such as, for example, color coding output or similar nonsense)
  • compile without warnings
  • work on a NetBSD 8.x system

Hints

Given the number of aspects covered in this assignment, I would suggest that you try to implement features incrementally in the following order:

Shell startup, options parsing, command parsing / tokenization

Begin by implementing the standard getopt(3) flow, initialize your world, print a command-line prompt and read input from the controlling terminal.

Split the given string into tokens.

Make sure your shell can't be terminated by Ctrl+C, and can be exited successfully.

Builtins

Implement all listed builtins with all supported arguments / exit status. Resist the temptation to implement additional features not requested in the assignment.

Fork-exec commands

Create a new process and execute commands. Wait for them to complete. Reap your children. Make their exit status available.

Implement I/O Redirection

Inspect the list of tokens for supported I/O redirection operators. Ensure no illegal combination is given. Implement the correct redirection. Make sure to handle error cases correctly and report meaningful errors to the user.

Implement pipelines

Split the input by the pipe operator before tokenization. Fork new processes for each command in the pipe, connect stdout/stdin as needed. Execute the commands.

Implement backgrounding of processes

Only implement placing commands into the background after all other functionality is present.

Testing

The manual page includes a list of examples. You should consider those basic minimum functionality that your shell should provide as shown there.

In your README, please elaborate on what other tests you considered.

Deliverables and Due Date

You will submit a single tar archive named username-sish.tar that will extract into a directory named after your username. Make sure to include all the files as required by the general homework submission guidelines.

The due date for this assignment is 2018-12-17 18:00. Please attach the file to an email sent from your @stevens.edu email address to jschauma@stevens.edu with a subject of "[CS631] sish".


[Course Website]