Rebuild. Unix Shell (C language)
Overview
A Unix shell implemented in C that replicates core bash behavior.
Supports command parsing, pipelines, redirections, environment variables, built-ins, and interactive signal handling.
Source Code
Purpose
- Rebuild a Unix shell from scratch to understand process control and I/O
- Practice low-level systems programming using POSIX APIs
- Gain deep familiarity with parsing, execution models, and shell semantics
Technical Highlights
- Custom tokenizer and command parser
- Pipelines and redirections:
<,>,>>,<<(heredoc) - Built-in commands:
cd,echo,pwd,export,unset,env,exit - Environment variable expansion and quoting rules
- Process control via
fork,execve,pipe, anddup2 - Interactive signal handling (
SIGINT,SIGQUIT,EOF) - GNU Readline integration for history and line editing
Architecture
- Structured command representation with linked pipelines
- Clear separation between parsing, execution, and redirection layers
- Manual memory management validated with Valgrind
- Leak suppressions for external libraries (readline)
Outcome
- Fully functional interactive shell matching expected
bashbehavior - Leak-free execution under Valgrind, including child processes
- Strong foundation for understanding shell injection, parsing bugs, and process-level behavior