Context
Operating Systems coursework asked for a 'shell that handles a few commands.' I read the assignment, then read the bash source. The gap between those two felt like the actual lesson.
Custom Unix shell from scratch.
Operating Systems coursework asked for a 'shell that handles a few commands.' I read the assignment, then read the bash source. The gap between those two felt like the actual lesson.
Implement a working Unix-like shell in C with proper process management — fork, exec, wait, signals, piping, redirection, history, and a small set of built-ins (cd, pwd, exit, history, kill).
Wrote the shell from scratch as a REPL with a hand-rolled tokenizer, a recursive-descent parser for command pipelines, and explicit syscall management. No external libraries beyond libc.
Working shell that ran most common pipelines I threw at it. Top marks on the assignment. More importantly, I never look at `bash` the same way.
I would have started with a real grammar definition. Hand-rolling the parser was educational but it's the part I'd most want to throw away if I touched the project again.