A minimal Bash shell clone developed as part of the 42 School curriculum.
This project challenges you to dive deep into shell programming, system calls, and teamwork while delivering a functional and interactive command-line interface.
Minishell is a core project at 42 School where students create a simplified version of Bash. It emphasizes understanding key components of shell functionality, such as:
- Parsing commands and handling syntax.
- Managing system processes with
fork
,exec
, andwait
. - Handling pipes, redirections, and environment variables.
- Implementing built-in commands like
echo
,cd
,pwd
,env
,export
,unset
, andexit
.
This project not only develops low-level programming skills but also instills problem-solving and collaboration practices.
- Prompt Display: Shows the shell prompt, waiting for user input.
- Command Execution: Handles executables from
$PATH
and local directories. - Built-in Commands: Implements core shell commands:
echo
(with-n
option).cd
(relative/absolute paths).pwd
,env
,export
,unset
, andexit
.
- Environment Variables: Expands variables like
$HOME
or$USER
.
- Pipes (
|
): Redirect output from one command to the input of another. - Redirections: Supports operators like
>
,>>
,<
, and<<
. - Command History: Navigate previous commands with arrow keys.
Compiles different program pieces and builds a final executable
make [RULE]
Rule | Description |
---|---|
all |
Default rule, compiles the mandatory part |
clean |
Removes all the objects file of the project |
fclean |
Removes some of the temporary files of the project (.o and .a) |
fclean |
Removes all the temporary files of the project (.o, .a and executables) |
Clone the repository and compile the project:
git clone https://github.com/dhsudev/minishell.git
cd minishell
make
Launch Minishell:
./minishell
To exit the shell, type:
exit
- Lexical Analysis & Parsing: Breaking down user input into tokens and parsing commands to interpret their structure.
- Process Management: Leveraging fork, execve, and waitpid for running commands and handling child processes.
- Signal Handling: Responding gracefully to signals like Ctrl+C (interrupt).
- Memory Management: Avoiding memory leaks and ensuring efficient usage.
Handling edge cases in redirections, piping, and variable expansions. Ensuring compliance with POSIX standards while maintaining simplicity.