A miniature version of a Unix shell written in C.
A shell provides users with an interface to the Unix system. It gathers input and executes programs based on that input. When a program finishes executing, it displays that program's output.
A shell is an environment in which we can run our commands, programs, and shell scripts. There are different flavors of a shell, just as there are different flavors of operating systems. Each flavor of shell has its own set of recognized commands and functions. 1
This program was developed as part of an assignment for Oregon State University's CS 344 Operating Systems course. The assignment requirements are available here.
This program has the following features:
Small shell creates a terminal or shell for the user to process typical Unix commands with.
Small shell ignores blank lines, excess whitespace, and lines beginning with the
#symbol (comments).Small shell expands
$$strings within arguments passed to the shell and expands them into the shell's process ID (PID).Small shell has custom-built
exit,cd, andstatuscommands.Small shell can execute other programs (and Unix commands) by running small shell in the same path as the program to be run.
Small shell can redirect input and output using the "<" and ">" arguments respectively.
Example: The command wc < file1 > file 2 will call the wc command using file1 in place of standard input (stdin) and print the results to file2 in place of standard output (stdout).
Small shell can run children processes in the foreground (default) or in the background by using "&" as the last argument. This command does not work with the
exit,cd, orstatuscommands.Small shell has built-in handling for SIGINT (CTRL+C) and SIGTSTP (CTRL+Z) signals. SIGINT signals are ignored by small shell, but terminate children processes running in the foreground only. SIGTSTP prevents children processes from running in the background and can be toggled on and off.
System Requirements: Unix (Linux, Mac OS, or WSL2)
Clone the repository.
In your terminal, navigate to the project directory.
Compile by using the command
gcc --std=gnu99 -o smallsh main.c.Run the file by using the command
./smallsh.
In your terminal, navigate to the project directory. Ensure the program has already been compiled per the above instructions.
Test using the command:
p3testscript 2>&1.
