You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project has been created as part of the 42 curriculum by aykrifa, cbordeau.
Minishell
Description
Minishell is a minimal Unix shell written in C, built as part of the 42 school curriculum. The goal is to reproduce the core behavior of Bash — from command parsing and execution to redirections, pipes, signals, and built-in commands.
The shell is built around an Abstract Syntax Tree (AST) — each command line is parsed into a tree of nodes (EXEC, PIPE, REDIR, LINE) that is then walked recursively at execution time. This architecture is directly inspired by the shell from the xv6 RISC-V teaching kernel by MIT, extended with full Bash quoting rules, environment variable expansion, here-doc, wildcards, and logical operators.
Features
Core
Interactive prompt with command history (via GNU Readline)
Command lookup via PATH, relative path, or absolute path
Single global variable for signal number only (Norm-compliant)
Quoting
'single quotes' — no interpretation of any metacharacter
$? — expand exit status of last foreground pipeline
* — wildcard glob for current working directory (bonus)
Signals
Signal
Interactive behavior
Ctrl-C
Display new prompt on a new line
Ctrl-D
Exit the shell
Ctrl-\
Does nothing
Built-in Commands
Command
Description
echo [-n]
Print arguments to stdout, -n suppresses trailing newline
cd <path>
Change working directory (relative or absolute)
pwd
Print current working directory
export [VAR=val]
Set or display environment variables
unset <VAR>
Remove an environment variable
env
Print all environment variables
exit [n]
Exit the shell with optional status code
Instructions
Requirements
cc (GCC or Clang)
GNU Readline library (libreadline-dev on Debian/Ubuntu)
make
Compilation
make
This compiles libft then the shell. The binary is minishell.
Running
./minishell
Makefile rules
Rule
Effect
make / make all
Build the project
make clean
Remove object files
make fclean
Remove object files and binary
make re
fclean + all
make bonus
Build with bonus features
Resources
References
xv6 RISC-V shell — MIT 6.1810 teaching OS. The AST-based parser and recursive tree executor in this project are directly inspired by user/sh.c from the xv6-riscv source: https://github.com/mit-pdos/xv6-riscv