A compact yet fully functional UNIX shell written in C.
This project replicates the core behavior of bash, implementing command parsing, built-in commands, pipes, redirections, environment variable expansion, and more — all from scratch.
The goal of Minishell is to understand how a real shell works internally:
how user input is parsed, commands are executed, and processes interact with the operating system.
This project builds a strong foundation in system programming, especially process handling, file descriptors, and command interpretation.
Clone and compile the project:
git clone https://github.com/mdomnik/minishell.git
cd minishell
makeRun the shell:
./minishellYou can exit the shell with:
exitecho(with-nflag)cd(supports relative, absolute, and-)pwdexport,unset,envexit
- Executes binaries found in
$PATH - Handles absolute and relative paths
- Preserves environment variables between commands
- Pipelines (
cmd1 | cmd2 | cmd3) - Input
<, output>, append>>redirections - Heredocs (
<<) with proper delimiter behavior
$VARexpansion (inside double quotes)- Single quotes preserve literal strings
- Works with redirections and pipes
Ctrl+Cinterrupts current command but not the shellCtrl+\andCtrl+Dhandled gracefully
- Accurate exit codes (
$?) - Clear error messages for invalid commands, files, or paths
- Behavior aligned with
bash
The GIF demo above shows:
- Builtins such as
cd,echo,export,unset,env - External command execution (
ls,grep,wc,cat, etc.) - Redirections (
>,>>,<) and heredocs (<<) - Pipelining between commands
- Variable expansion and quoting rules
- Error handling and
$?exit status - Clean exit from the shell
- Custom lexer and parser for tokenizing input and building commands
- Use of
fork()/execve()for executing child processes - Management of
pipe()anddup2()for I/O redirections and pipelines - Environment variable storage and expansion logic
- Signal handling using
sigaction()to replicate bash-style behavior
.
├── minishell # Compiled shell binary
├── Makefile # Build rules
├── inc/ # Headers
├── src/ # Source code (lexer, parser, executor, builtins, utils, ...)
├── lib/ # libft (custom standard library)
├── obj/ # Object files
├── suppressions.supp # Valgrind suppression file
└── Showcase.gif # Feature demo
Maciej — @mdomnik
Kang — @donkeykang316
