A simple command shell

Upload via Moodle as: shell.tar or shell208.c

As usual, you are welcome to work with a partner if you wish.

Goals

Rubric

1 - support "help", printing a short summary of your shell's current features 3 - simplest mode: print prompt; get one-word command from user; execute command (or print an error message); repeat forever 3 - support single commands with command-line arguments (e.g., "wc -l file.txt" or "ls -l -a") 3 - support "command > file" (redirecting command's stdout to a file) 3 - support "command1 | command2" (redirecting one command's stdout to the stdin of a second command) 2 - code quality

Background

When you interact with a Unix (or other similar) command prompt, you are interacting with a program known as a command shell. This might be bash in a WSL or Linux terminal, bash in the terminal in VS Code, zsh in a macOS Terminal, PowerShell in Windows, cmd in a Windows "command prompt" window, etc.

Though command shells are typically sophisticated programs with many features and they often implement their own full-fledged programming languages (e.g., "bash scripting"), their flow of control is, at heart, conceptually very simple:

  1. print a prompt for the user
  2. read the user's command
  3. execute the command
  4. wait for the command to finish
  5. go to step 1

Your assignment

You will write a simple command shell, named shell208, that performs the most common operations that shells perform. For this project, you will implement the styles of operation listed in the rubric above.

Your shell should be able to handle single-word commands, commands with command-line arguments, redirection of standard output to a file, and redirection of standard output to the standard input of a second command. For example, each of the following should work as they do in bash on mantis:

shell208$ help shell208$ ls shell208$ ls -l mysubdirectory shell208$ ls -l > listing.txt shell208$ ls -a | wc -l

Submitting your work

Submit your program via Moodle in one of two forms.

Help

I have posted:

Have fun!

This program is pretty cool once you get it working.