Custom Shell
GitHub →A POSIX-style shell written in C from scratch, built with Jason Ng for Stuyvesant’s Systems Programming course. It parses and executes commands via execvp, with its own handling for piping, redirection, and signals rather than relying on a library.
The codebase is split by responsibility: parse.c tokenizes input and flags redirection operators, redirect.c and pipe.c handle the corresponding dup-based fd juggling, and shellcmd.c handles execution plus the [user@machine:path]$ prompt.
Features
cdandexitbuiltins- Redirection (
<,>,>>) and piping (|) Ctrl+Csignal handling that kills only the child process, not the shell- Multiple semicolon-separated commands per line
- Custom prompt showing user, host, and working directory
Known bugs
- Piping into a redirect (e.g.
cmd1 | cmd2 > file) fails to create the output file intermittently cdwith no arguments doesn’t workls | wcreports the wrong length due to the temp-file-based piping implementationCtrl+Zbreaks the shell instead of suspending it- Occasionally needs
Ctrl+Dtwice to exit