Minishell is a project developed as part of the 42 school curriculum. It is an implementation of a Unix shell in the C language that offers basic command interpreter functionality, including parsing, command execution, redirection, pipes, and environment variable manipulation.
In this project, I had to work with advanced concepts such as memory management, processes, signals, and complex data structures such as abstract syntax trees (AST).
- Lexer: Tokenization of user input
- Parser: Abstract syntax tree (AST) construction
- Executor: Command execution with support for pipes and redirections
- Builtins: Implemented internal commands (echo, cd, pwd, export, unset, env, exit)
- Expander: Expansion of environment variables and wildcards
- Heredoc: Support for heredoc with conditional variable expansion
- Signals: Proper handling of signals (SIGINT, SIGQUIT)
- History: Command history with readline
- Process Management: Fork, exec, wait
- Redirections:
<,>,>>,<< - Pipes: Communication between processes
- Logical Operators:
&&,||with short-circuiting - Subshells: Execution in subprocesses with parentheses
- Environment Variables: Complete environment manipulation
- Wildcards: Pattern expansion with
*
- GCC Compiler
- Readline Library
- Make
- Libft Library (already included)
# Compile
make
# Clean Object Files
make clean
# Clean All
make fclean
# Recompile
make re
# Debugging
make valgrind./minishell# Basic Command
ls -la
echo "Hello World"
pwd
# Redirects
echo "test" > file.txt
cat < file.txt
# Pipes
ls -la | grep ".c"
# Heredoc
cat << EOF
Hello
World
EOF
# Logic Operators
echo "success" && echo "also success"
echo "fail" || echo "this will print"
# Environment Variables
export MY_VAR="value"
echo $MY_VAR
unset MY_VAR
# Subshells
(cd /tmp && ls)| Command | Description | Features |
|---|---|---|
echo |
Displays arguments | Supports -n flag, multiple arguments |
cd |
Changes directory | Supports ~, -, --, updates PWD/OLDPWD |
pwd |
Displays current directory | Absolute path |
export |
Sets/exports variables | Creates/updates environment variables |
unset |
Removes variables | Removes variables from the environment |
env |
Displays environment | Lists all environment variables |
exit |
Exits shell | Optional exit code, resource cleanup |

