Principles of Operating Systems I Programming Assignment 1
A simple shell using the POSIX system call API.
To run the project, use the following commands in the terminal:
make
./mash.exe
Once started, the user will be given a prompt that shows the current working directory (e.g.: /home/csci4401>
), and the shell enters an infinite loop where it takes user commands and executes them.
Mash implements the cd
and pwd
commands that allow a user to change the current directory and to print the current directory, respectively. The exit command allows orderly shell exit.
Unless the user types in a built-in command, any other input will be interpreted as an effort to run an executable. In response, Mash will fork()
a process, execute the command and show the output (e.g.: ls -l
).
Mash allows redirection of standard input/output streams to/from a file. E.g:
ls -l > output
sort alice.txt > sorted.txt o sort < alice.txt > sorted.txt
Mash allows IPC via pipes. E.g.: ls -l | grep sh | wc -l