A custom, fully functional Unix shell built from scratch in bare-metal C.
This project was developed to gain a deep, unabstracted understanding of operating system mechanics, process management, and kernel-level inter-process communication (IPC). It directly interacts with Linux system calls to manage memory, execute programs, and route data streams.
- Process Creation & Control: Utilizes
fork(),execvp(), andwait()to spawn and manage child processes safely within the parent shell environment. - Pipeline Support: Handles complex multi-stage pipelines (e.g.,
ls -la | grep .c | wc -l) with dynamic pipe allocation, efficient file descriptor routing, and proper cleanup to prevent deadlocks. - Two-Phase Parsing: Implements a strict parsing algorithm to handle both pipe operators and command arguments without
strtokstate corruption. - Built-in Commands: Supports
cdandexitcommands executed directly in the parent process. - Error Handling: Comprehensive error checking and reporting for system calls.
| Component | Details |
|---|---|
| Language | C (C99 standard) |
| Build System | GNU Make |
| Environment | Linux (kernel 4.4+) |
| Key APIs | fork(), execvp(), pipe(), dup2(), wait(), chdir() |
| Compiler | GCC with strict warnings enabled |
Ensure you have gcc and make installed:
# Clone the repository
git clone https://github.com/yansh07/abyss-shell.git
cd abyss-shell
# Build the shell
make
# Run the shell
make runOnce built, run the shell:
./bin/abyss-shellThen use standard Unix commands:
abyss-shell> ls -l | grep .c
abyss-shell> cat file.txt | sort | uniq
abyss-shell> pwd
abyss-shell> cd /path/to/dir
abyss-shell> exitmake— Compile the executablemake run— Build and run the shellmake clean— Remove build artifactsmake help— Show available targets
MIT License — See LICENSE file for details.