CPSC 331 Operating Systems Spring 2026

Project 2
Shell

Due: Wed 2/18 at the start of class

This project has several goals:

Your task is to implement a simplified version of the Unix shell largely as described in the project README.

Collaboration and the Use of AI

Review the course policy on academic integrity.

Certain uses of AI are permitted on this assignment. AI use is not required.

The basic rule: you may use the code completion features of Copilot but may not use features (such as the coding agent) where code is generated from English language prompts. It is also essential that you understand and think critically about any code suggested by Copilot, both to help develop your C programming skills and because while the code suggestions are often uncannily on target, they are not always exactly what you want.

Using the code explanation features of Copilot Chat is permitted, though be careful that this doesn't spill over into code generation.

Other Policies

Review the policy on late work.

Revise and resubmit applies for this assignment. Review the details of how revise and resubmit works.

Handin

To hand in your project:

Check that the handin was successful and that the directory structure is correct: your handin folder /classes/cs331/handin/username should contain a folder processes-shell which in turn contains a Makefile, a file wish.c, and, if you added any test cases, a subdirectory tests containing the appropriate files.


Preliminaries

Do the steps outlined in reddish boxes below before you start writing code.

Provided Code

The processes-shell/tests directory contains test cases for your shell. Run them from the command line: change to your processes-shell directory as needed, then run

    ./test-wish.sh

Treat the provided tests as a backup check: practice your testing skills by first doing your own testing, then run the provided tests to see if you missed anything. Also note that the provided tests run your shell in batch mode, so you'll need that functionality before you can run any tests.

The tester directory (copied as part of the setup for the previous project) contains scripts for running the provided tests along with a README that describes the setup for each test case. There's no need to do anything with the contents of this directory unless you want to define your own test cases.

Extra credit is possible if you find cases missed by the provided tests — see the README in the tester directory for information on how to define a test case and hand in the files for your new case(s) along with your code. Be sure to number your test cases starting one higher than the provided ones — don't modify or replace the provided test cases — and include a description of what the test case covers in the appropriate file.

Reference

Also see the Reference section from the previous project.

System Calls and Library Routines

Look up system calls and library routines in the man pages to find out more about them even if the README or handout tells you what to use. Pay careful attention to the #includes needed along with the descriptions and return values.

A few particular notes:

Strings

There is a lot of string manipulation needed for this project, and, in fact, that is likely the most challenging part of the project. Working with strings looks very different in C than it does in Java — in Java, String is a built-in object with methods and automatic memory management. In C, a string is simply a sequence of characters stored in memory and terminated by a special null character ('\0'). You do not call methods on strings — instead, you pass character arrays (or pointers to them) to library functions. This means you must be aware of where memory comes from, how long it remains valid, and whether operations modify the data in place.

Dive Into Systems also has some reference material on strings and arrays:


Specifications and Details

Your task is to implement a simplified version of the Unix shell largely as described in the project README.

To do this:

Additional or modified specifications:

Hints/suggestions: