A beautiful, minimalistic reimplementation of the Unix shell in C, following the strict guidelines of the 42 school curriculum. This project recreates essential features of Bash, including parsing, execution, built-in commands, redirections, pipes, and environment handling, while respecting the complexities of UNIX signal management and memory hygiene.
- Custom shell prompt with interactive input using
readline - Command execution via:
- Absolute and relative paths
$PATHlookup
- Quoting support:
'single quotes'— literal interpretation"double quotes"— expansion of$VARIABLES
- Environment variable expansion (
$VAR,$?) - Proper handling of:
Ctrl-C— interrupts and redraws promptCtrl-D— exits shellCtrl-\— ignored
echo [-n]— print argumentscd [dir]— change working directorypwd— print current directoryexport [VAR=VALUE]— add/update environment variableunset [VAR]— remove environment variableenv— print environmentexit— exit shell
<— redirect input>— redirect output (overwrite)>>— redirect output (append)<<— heredoc (input until delimiter)
- Pipes (
|) for chaining commands - Proper child process handling
- Exit code tracking with
$?
&&and||logical operators with()for priority- Wildcard
*expansion (glob) in current directory
- Unix-like environment
- GCC compiler
readlinelibrary
make./minishellmake/make all— builds the projectmake clean— removes object filesmake fclean— removes all generated filesmake re— rebuilds everything from scratch
- Only one global variable allowed (signal handling only)
- Memory leaks must be avoided (except from
readline) - External functions limited to an approved list
- Follow Bash behavior wherever applicable
This project is part of the 42 School Curriculum and adheres to their academic integrity rules. Sharing or using this code outside the intended scope is discouraged.