A simple shell implementation as part of the 42 curriculum.
Minishell is a simplified version of a shell (command-line interpreter) that implements basic shell functionality:
- Command execution
- Built-in commands
- Environment variable expansion
- Redirections and pipes
- Signal handling
- Marcel - Lexer, parser, memory management
- Lada - Command execution, built-ins, environment handling
- Lexical analysis (tokenization)
- Memory management
- Command execution
- Built-in commands
- Redirections
- Pipes
- Environment variables
- Signal handling
The project uses a Valgrind suppression file to ignore "still reachable" memory associated with the readline library. According to the subject requirements, we are not required to fix readline memory leaks.
There is a 5-byte "still reachable" memory block from a static variable last_executed in the handle_input function (shell_loop.c). This is not a true leak as it's intentionally kept alive for the duration of the program to track command history behavior, and will be reclaimed by the OS at program termination.
-
Complete Lexical Analysis
- Basic tokenization
- Handle quotes (single and double)
- Extract environment variables
- Fix memory leaks in token parsing
-
Parser Implementation
- Create abstract syntax tree (AST)
- Handle command separation
- Implement syntax validation
-
Error Handling
- Implement error messages
- Add syntax error detection
- Create graceful error recovery
-
History Management
- Implement command history
- Handle history file operations
-
Signal Handling Support
- Set up signal handlers
- Implement behavior for Ctrl+C, Ctrl+D, Ctrl+\
-
Environment Variable Management
- Environment variable storage
- Variable expansion
- Handle $? special variable
-
Command Execution
- Implement path resolution
- Handle command execution (execve)
- Manage process forking
-
Built-in Commands
- echo with -n option
- cd with relative/absolute paths
- pwd
- export
- unset
- env
- exit
-
Redirection Implementation
- Input redirection (<)
- Output redirection (>)
- Append output (>>)
- Heredoc (<<)
-
Pipes
- Implement pipe functionality
- Handle multiple pipes
./run-minishell.sh normal./run-minishell.sh valgrind./run-minishell.sh suppressed