This project has been created as part of the 42 curriculum by lutsiara.
Minishell is a project that aims to create a simple, functional shell, similar to a mini version of Bash. It provides a platform to gain extensive knowledge about processes, file descriptors, and command-line parsing.
Key features include:
- Interactive command-line interface with history.
- Handling of absolute and relative paths.
- Built-in commands: echo, cd, pwd, export, unset, env, and exit.
- Pipelines (|) for chaining commands.
- Redirections (<, >, <<, >>).
- Environment variable expansion ($VAR, $?).
- Logical operators (&&, ||).
- Wildcard expansion (*).
- Signal handling (Ctrl-C, Ctrl-D, Ctrl-\).
Minishell is structured into several modular components to ensure clean separation of concerns and maintainability:
- Lexer (lexer.c): Tokenizes the input string into a list of meaningful tokens (words, operators, etc.).
- Expander (expander.c): Processes tokens to handle environment variable expansion and quote removal.
- Parser (parser.c): Converts the sequence of tokens into a linked list of t_command structures, which hold the command arguments, file descriptors for input/output, and logical operators.
- Executor (executor.c): The core engine that orchestrates command execution. It manages:
- Built-in commands via direct execution.
- External commands via path searching and execve.
- Pipelines and redirections using fork, pipe, and dup2.
- Environment Management (environment.c): Maintains a linked list representing the shell's environment variables.
- Built-ins (src/builtins/): Individual modules for each mandatory shell built-in command.
To compile the project, use the provided Makefile:
To remove all compiled objects and binaries:
To recompile:
Once compiled, run the shell: