K2SH is a lightweight, custom-built shell implemented in C. It supports basic command execution, built-in functions, and pipelines using |. I built this to learn how Unix-like shells work under the hood.
- Run external commands (e.g.,
ls,grep,cat) - Execute pipelines like
ls | grep txt - Built-in commands:
cd– Change directorypwd– Print working directoryecho– Print texthistory– Show command historyhelp– List built-in commandsexit– Exit the shell
- Tracks command history (up to 1000 entries)
- Modular design with a clean
Makefilefor building and running
The project includes a flexible Makefile with debug and release modes.
makemake release./k2shOr with Makefile
make run # Runs the debug version
make run-release # Runs the optimized version