Minishell is a 42 School project that implements the basic features of a shell like Bash.
This version includes all mandatory requirements, the bonus, and some additional features.
Interactive command line: Clean prompt with command historyCommand execution: PATH resolution, absolute/relative executionProcess management: Fork/exec model with proper signal handlingEnvironment variables: Full support for variable expansion and manipulationI/O redirection: Input/output redirection with append modePipes: Command chaining with pipe operatorsHeredoc: Advanced input redirection mechanismsSyntax checking: Detection and reporting of syntax errors
Command substitution:$()for command substitutionNon-interactive mode:-coption to run commands directlyHerestring:<<<for direct string inputHeredoc expansion: Variables and commands inside heredoc and herestringQuote handling: Advanced single and double quote processingCharacter escaping: Support for\(backslash)Unclosed tokens: Displays PS2 for line continuation
Shell variables: Local variables in addition to environment variablesSpecial variables:$$- Shell PID$RANDOM- Random number$TIME- Current timestamp$_- Last argument of the previous command$?- Last exit code
Tilde expansion:~expands to the home directoryWildcard expansion:*,?, and[a-z]with advanced patterns
Logical operators:&&and||with parenthesis support for precedenceSubshells:()for execution in subprocessesConcurrent execution: Handling of multiple processes
All builtins include --help and --version:
echo- With-nand-eoptionscd- Withcd -support (previous directory)pwd- Current directoryexport- Environment variable managementunset- Remove variablesenv- With-sto show shell variablesexit- Exit the shellhistory- Command history managementhelp- Built-in help systembanner- Welcome message
git clone git@github.com:Kobayashi82/Minishell.git
cd minishell
make# Start minishell
./minishell
# Basic example
minishell$ echo "Hello World"
Hello World# Run commands directly
./minishell -c "echo 'Hello from the command line'"
./minishell -c "ls -la | grep '.c' | wc -l"
./minishell -c "export VAR=value && echo \$VAR"
# Complex commands with pipes and redirection
./minishell -c "cat /etc/passwd | grep root > users.txt"# Pipe usage
minishell$ ls -la | grep ".c" | wc -l
# Redirection
minishell$ echo "content" > file.txt
minishell$ cat < file.txt
# Variables
minishell$ export VAR="value"
minishell$ echo $VAR
# Heredoc
minishell$ cat << EOF
> line 1
> line 2
> EOFminishell$ echo "Current date: $(date)"
Current date: Mon 26 May 2025 10:30:15 CEST
minishell$ files=$(ls *.c)
minishell$ echo $filesminishell$ make && echo "Build succeeded" || echo "Build failed"
minishell$ (cd /tmp && pwd) && pwd
/tmp
/original/pathminishell$ ls *.c # .c files
minishell$ ls file?.txt # file1.txt, file2.txt, etc.
minishell$ ls [a-z]*.c # .c files starting with lowercaseminishell$ cat <<< "This is a line of text"
This is a line of text
minishell$ bc <<< "2+2"
4- β No memory leaks: Full heap cleanup
- β No open file descriptors: Properly closes all FDs
- β
Signal handling: Robust handling of
SIGINT,SIGQUIT,EOF
- β Identical error handling: Error codes and messages like Bash
- β
Signal behavior:
Ctrl-C,Ctrl-D,Ctrl-\like Bash - β Special variables: Identical behavior to Bash
- β Recursive parser: Complete syntax parsing
- β Error handling: Detailed error detection and reporting
- β Advanced tokenization: Support for complex tokens
This project is licensed under the WTFPL β Do What the Fuck You Want to Public License.
π Developed as part of the 42 School curriculum π
"In Minishell, the last feature is never really the last"

