A functional Unix shell written in C, implementing core Bash behavior including pipes, redirections, environment variables, and builtins.
minishell replicates the essential behavior of bash: it reads user input, parses it into commands and arguments, handles quoting and variable expansion, executes commands with pipes and redirections, and manages environment variables. The project was built in pair programming.
- Interactive prompt with command history (via
readline) - Single and double quote handling
- Environment variable expansion (
$VAR,$?) - Redirections:
<,>,>>,<<(heredoc) - Pipes:
cmd1 | cmd2 | cmd3 - Signals:
Ctrl-C,Ctrl-D,Ctrl-\behave as in bash
| Command | Description |
|---|---|
echo |
Print arguments (-n flag supported) |
cd |
Change directory |
pwd |
Print working directory |
export |
Set environment variable |
unset |
Remove environment variable |
env |
Print environment |
exit |
Exit shell with status code |
readline → lexer (tokenize) → parser (AST) → executor
├── builtin? → run builtin
└── external? → fork → execve
pipes → connect stdin/stdout with pipe()
redirections → dup2()
- Language: C
- Library:
readline(history, input) - Key concepts: process forking (
fork,execve,waitpid), file descriptor manipulation (dup2,pipe), lexing and parsing, signal handling
| Field | Value |
|---|---|
| Project | minishell |
| Circle | 3 |
| Norminette | Compliant |
- Full shell execution model: lexer → parser → executor
- Process management:
fork,execve,waitpid, exit status - File descriptor duplication and pipe chaining
- Signal handling inside a REPL
- Collaborative development (pair programming at 42)