Minishell is a minimalist Unix shell implementation created as part of the 42 school curriculum. This project teaches the fundamentals of process creation, file descriptors, and shell programming by recreating a functional shell with many of Bash's core features.
Key features include:
- Command execution with PATH resolution
- Environment variable expansion
- Redirections (
>,>>,<,<<) - Pipes (
|) - Signal handling (Ctrl-C, Ctrl-D, Ctrl-)
- Built-in commands (
echo,cd,pwd,export,unset,env,exit) - Single and double quote handling
- C Compiler (
cc/gcc/clang) - GNU Make
- readline library (install with
brew install readlineon macOS orsudo apt-get install libreadline-devon Ubuntu)
git clone https://github.com/mtelek/minishell.git
cd minishell
makeThis will create an executable named minishell.
Run the shell with:
./minishellYou'll see a prompt where you can enter commands just like in Bash.
To exit, either:
- Type
exit - Or press
Ctrl-D
Here's how Minishell compares to Bash in various scenarios:
| Test Case | Bash Output | Minishell Output | Status |
|---|---|---|---|
echo "Hello $USER" |
Hello username |
Hello username |
✅ |
ls > file.txt |
Creates file | Creates file | ✅ |
cat < file.txt |
File contents | File contents | ✅ |
echo -n "No newline" |
No newline | No newline | ✅ |
export TEST=value |
Sets variable | Sets variable | ✅ |
echo $TEST |
value |
value |
✅ |
unset TEST |
Removes variable | Removes variable | ✅ |
exit 42 |
Exits with 42 | Exits with 42 | ✅ |