Minishell is a custom Unix-like command-line shell written in C as part of the 42 School curriculum.
It aims to mimic core behaviors of Bash by handling commands, built-ins, environment variables, redirections, pipes, and signals using low-level POSIX system calls.
A shell is a command interpreter that reads user input, parses it, and executes system commands and built-ins.
This project deepens your understanding of:
- Process creation and management with
fork,execve,waitpid, etc. :contentReference - Input parsing and syntax handling
- File descriptor redirection and pipes (
|,<,>,>>,<<) :contentReference - Signal handling (e.g.,
Ctrl+C,Ctrl+D,Ctrl+\\) :contentReference - Environment variable expansion (
$HOME,$?, etc.) :contentReference
Minishell respects the 42 coding standards (Norminette) and is fully implemented in C.
- Prompt display and user input loop
- Execution of system commands found in
$PATH - Built-in commands:
echocdpwdexportunsetenvexit
- Environment variable expansion
- Redirections:
>,>>,<,<<(here-document) - Pipes (
|) - Signal handling for typical interactive shell behavior
(Include here any bonus features you have — e.g., wildcard expansion, logical operators &&/||, enhanced line editing, etc.)
Minishell is written in C and relies on:
- POSIX-compatible system calls
- GNU Make
- A C compiler (
gccor compatible)
-
Clone the repository
git clone https://github.com/mohos26/Minishell.git cd Minishell -
Compile
make
-
Run the shell
./minishell
You should see your custom shell prompt. Now you can type commands!
Inside the shell:
$ echo Hello World
Hello World
$ pwd
/home/user
$ ls -l | grep txt
$ export MYVAR=42
$ echo $MYVAR
42
$ exit(Adjust examples based on features you’ve implemented.)
- Input Reading: Read user input line.
- Lexing & Parsing: Tokenize input and build command structures.
- Execution: Fork processes and run external commands or built-ins.
- Redirections/Pipes: Manage file descriptors for command chaining.
- Cleanup: Free allocated memory and handle signals.
Minishell/
├── Makefile
├── src/
├── includes/
├── utils/
├── header.h
├── parser.c
├── executor.c
└── ...
(Adjust to match your repository’s actual structure.)
You can add a test suite or use external testers like minishell_tester (if you have one) to validate behavior against Bash.
Thanks to the 42 School curriculum and community for the project specifications and inspiration.