- Interactive prompt with
readline-backed line editing and history - Executable resolution via
PATH, plus absolute/relative paths - Single and double quote parsing, including nested and adjacent quoting
- Variable expansion (
$VAR,$?) inside double quotes and bare words - Pipelines (
|) with correct file-descriptor wiring across arbitrarily many stages - Full redirection suite:
<,>,>>,<<(heredoc) bash-compatible signal handling forCtrl+C,Ctrl+D,Ctrl+\- Builtins implemented in-process (no
forkforcd,export, etc., matching real shell semantics)
main.c → readline prompt → tokenizer → parser → expansion → execution
├── builtins (in-process)
└── pipeline (fork/exec/pipe/wait)
| Module | Responsibility |
|---|---|
parsing/ |
Tokenization, quote handling, AST/command-list construction, syntax validation |
execution/ |
Process management: fork/exec, pipe wiring, redirections, exit-status propagation |
builtins/ |
echo, cd, pwd, export, unset, env, exit |
utils/ |
String, memory, and environment-array helpers shared across modules |
libft/ |
Custom C utility library, linked into every module |
Commands are processed in four stages: tokenize → parse (build command structures, validate syntax) → expand (resolve $VAR/$?) → execute (fork children, wire pipes/redirections, wait).
Requirements: gcc/cc, make, an internet connection for the first build (downloads readline 8.2)
make # downloads + builds readline 8.2, builds libft, compiles minishell
./minishellmake clean # remove object files
make fclean # remove object files, binary, and the vendored readline build
make re # fclean + buildThe first build takes longer since it compiles readline from source; subsequent builds are fast.
| Command | Syntax | Description |
|---|---|---|
echo |
echo [-n] [text...] |
Print text, -n suppresses the trailing newline |
cd |
cd [path] |
Change directory (relative/absolute) |
pwd |
pwd |
Print the working directory |
export |
export [VAR=value] |
Set or display environment variables |
unset |
unset [VAR] |
Remove an environment variable |
env |
env |
List environment variables |
exit |
exit [status] |
Exit with an optional status code |
minishell> echo "Goodbye, World?"
Goodbye, World?
minishell> ls -la | grep minishell > output.txt
minishell> cat << EOF | sort | uniq >> results.txt
heredoc line 1
heredoc line 2
EOF
minishell> export MY_VAR="test value"
minishell> echo "Value: $MY_VAR, Exit code: $?"
Value: test value, Exit code: 0
minishell> export USER="Melovi"
minishell> echo "'Hello $USER'" vs '"Hello $USER"'
'Hello Melovi' vs "Hello $USER".
├── srcs/
│ ├── builtins/ # echo, cd, pwd, export, unset, env, exit
│ ├── execution/ # Process management and execution
│ ├── parsing/ # Tokenization and command parsing
│ ├── utils/ # Helper functions
│ └── main.c
├── includes/ # Headers and prototypes
├── libft/ # Custom C utility library
└── supps/ # Valgrind/readline suppression files
- No arrow-key history navigation (only
readline's in-session line editing) - Backslash escaping is not implemented
- No command substitution (
`cmd`/$(cmd)) or wildcard/glob expansion
