In this project, I implemented a Unix shell called wsh, capable of running both interactive and batch modes. The shell supports:
- Built-in commands:
exit,cd,local,export, andvars. - Process execution: Using
fork()andexecv()to run external programs. - Input/output redirection: Handling
<and>for file-based input and output. - Environment and shell variables: Supporting local and exported variables.
- Script execution: Running scripts with
#!./wsh.
The project required careful command parsing, process management, and memory safety checks, ensuring that wsh behaves similarly to a standard Unix shell.
This assignment provided valuable experience in systems programming and shell design. Key takeaways include:
β
Process creation and execution β Using fork() and execv() to manage child processes.
β
File redirection β Implementing < and > to manipulate stdin and stdout.
β
Shell variable handling β Managing local and environment variables correctly.
β
Script execution β Understanding how the shell interprets and runs script files.
β
Memory safety and debugging β Avoiding memory leaks and ensuring robust error handling.
I successfully implemented all required features of wsh, passing all test cases, and received 100% on the assignment. This project strengthened my understanding of process control, shell internals, and Unix system programming.
To run this shell, simply clone this repository to anywhere on your computer and run ./wsh. (You need to be in a unix environment or running bash, zsh, or something similar).
Once you've ran the shell, then you can do whatever there is to do on your previous shell!
[hdoll@royal-22] (33)$ ./wsh
wsh> echo hello world
hello world
wsh>