Lab 1 - A Simple UNIX Shell

COP4610/CGS5765, Introduction to Operating Systems, Fall 2003
Department of Computer Science, Florida State University

Points: 100 points.
Due: Week 6, Tuesday, September 30, 2003.

Purpose: To know how to use Unix system calls to create new processes, deal with signals, and have working knowledge of developing a command-interpreter interface, i.e., a shell program.

Assignment: Write a Unix shell program which acts as a command-interpreter interface between the UNIX operating system and the user using system calls. Some commands will be built into the shell itself, which means that those built-in commands only change internal status of your shell program. Commands that are built into the shell are:

Any additional input is assumed to be an executable program with the following format:
       command argument_1 argument_2 ....
A command may not require any arguments. Here an empty line is also a legal input and your shell should be simply ready to accept another command. If the input command contains a slash character, the corresponding file will be used directly. Otherwise, your shell program will first try to find the program by searching through the directories specified in MYPATH first. Then your shell will attempt to run the program (using fork and execve system calls to create a child process). For external commands, your shell program should allow the following features.

For the basic requirement, no more than one special control character ('&', '<', '>', '|', ';') (except '!') is allowed in any command and these special control characters only apply to external commands. You can also assume that there will be at least one white space before and after each special control character unless it is the very last one in the command line.

Additionally, your shell should be able to handle CTRL-C in the following way. If a program is running in the foreground mode, your shell should ignore signal CTRL-C. However when no program is running in the foreground mode, your shell should abort the user's current input and start to accept a new command.

Your shell should use the same syntax as csh, a popular Unix shell, which means that your shell should behave similarly to csh given the samilar command. As in UNIX shells, these commands are case-sensitive. For example, your shell program shall NOT accept "MYCD" as a built-in command but as an external command.

Submission:

Extra Credit: Please state clearly in your report if you have implemented one or both of the following options for extra credit.

Grading:

Demonstration: For grading purpose, you will be required to schedule a time slot to demonstrate your program for the TA. One week's recitation sessions will be used for this demonstration purpose. If you fail to demonstrate your program before the deadline (given later), your program will be graded based on your source code and worst cases will be assumed.

Test Cases: In general, for this lab, you should compare the behaviors of your program with a csh program for similar commands. A detailed test plan will be made available so that you can test your program and the same test plan will be used for grading.

Additional Information: