Advanced - Unix: Writing a Shell Fall 2026

Submission Instructions

This homework will be submitted as a repository on the EECS GitLab server. The repository you submit will be a private Project with the name/path eecs201-adv-unix with akamil added as a Reporter. The branch submit will be the one that is checked.

To finish the submission process and get your submission score, you will need to run the autograder. You will need to SSH into the course server (see Basic - Intro):

local$ ssh uniqname@peritia.eecs.umich.edu

(the local$ referring to a shell prompt on your system)

and then run eecs201-test:

peritia$ eecs201-test adv-unix

(the peritia$ referring to a shell prompt on the server)

The repository should have the following directory structure, starting from the repository’s root:

/
|-- report.txt
|-- Makefile
|-- (source files)

Do not commit any build output (compiled executables and object code) or any file system data like .DS_STORE on macOS.

Presentation/Checkoff

In addition to submitting this assignment, you will need to attend a lab session after the deadline to discuss your work with the course staff. Refer to the course schedule for the window for doing so for this assignment.

As part of the discussion, be prepared to do the following:

I suggest keeping these in mind while doing the assignment, and writing down your thoughts so that you can review them before the checkoff.

Your overall score for the assignment will be a combination of your submission score and the presentation/checkoff score. Refer to the syllabus for the details.

Preface

This assignment can be done on both macOS and Linux.

First, we’ll need to acquire a set of starter files. This assignment can be done in C or C++, whichever you prefer Use your preferred method of downloading files from a given URL:

# C version
https://www.eecs.umich.edu/courses/eecs201/fa2026/files/assignments/adv-unix-c.tar.gz

# C++ version
https://www.eecs.umich.edu/courses/eecs201/fa2026/files/assignments/adv-unix-cpp.tar.gz

Inside these archives there is a starter file and a Makefile. You can compile the program by running $ make.

Programming with POSIX (10)

This week’s class survey asked if you think you could write a shell. No matter what your answer was, I believe that you are capable of writing a basic shell :)

One video briefly mentioned how proccesses are created in Unix by fork-ing and exec-ing. Let’s showcase some POSIX programming and get some practice reading man pages with this exercise. In this exercise you’ll be creating “µShell”, or “mush”, using C or C++ (whichever you prefer). mush is a simple, minimalist shell whose only job is to execute the commands presented to it.

Its specifications are:

Note that there are no built-in commands (besides exit and cd), job control, file redirection, or signal handling specified (if you want to, you can do them for personal edification).

Some helpful functions (the string processing ones are more for C; if you’re using C++ you might have other mechanisms that fulfill the same role):

You can see documentation for these functions by using man. Sometimes, there may be multiple manpages for a given function. manpages have multiple sections: sections 2 and 3 are the programmer’s manual, with 2 being the operating system API and 3 being about library functions. You may often see things like fork(2): this refers to fork under section 2. You can specify a section to look at as an argument: man 2 fork.

Here are some helpful variables/macros for error checking:

You can read about them in the errno man page: man 3 errno.

Below is a sample way to structure the program. Remember that there are many different solutions possible:

1
2
3
4
5
6
7
8
9
10
11
12
13
// forever loop
  // print prompt
  // receive user input
  // handle EOF
  // tokenize input
  // handle "exit" and "cd"
  // handle non-builtins
    // fork
    // child
      // execute command
      // handle errors
    // parent
      // wait for child

In the file archive you downloaded, you can find a Makefile and starter file for your preferred language in the appropriate directory. You may only use the C standard library, the C++ standard library, and any POSIX function. When you work on this, keep in mind the header files required by each function: the manpages will tell you. This can be implemented in surprisingly little code: it’s possible to do this in less than 50 lines of plain old C!

For me the receiving and parsing input was the most difficult part of this.

This is an autograded assignment: you need to run the autograder to get credit. Make sure that your code is able to compile on the course server! You can clone your repo onto the course server if you create a keypair on the server and share that public key with the EECS GitLab.

It’s been noticed some compilers on macOS will implicitly handle the #include of certain POSIX header files while the compiler on the course server does not, resulting in a situation where code written on macOS will compile but not on the course server since the course server is more strict about the #includes. Be mindful of what #includes you need!

Things to keep in mind:

Report

Create a file report.txt in your repository’s root: <repo path>/report.txt. On the first line of the file, put down an estimate of how long you took to do this assignment in minutes as an integer (e.g. “37”, “84”: just numbers, no letters). On the second line and onwards of the file, put down what you learned (if anything) by doing this assignment. If you already knew how to do all of this, just put “N/A”.