This project was developed as part of the 42 curriculum by Breno Silva and Ronaldo Gomes.
This project consists of a shell application written in C. Its goal is to reproduce a subset of the behavior of the Bash shell, while being restricted to a limited set of allowed system calls and functions, in addition to our custom implementation of parts of the C Standard Library (libft).
The project emphasizes a deep understanding of several core topics of Unix systems programming, such as:
- Command parsing.
- Shell lifecycle.
- Unix files and file descriptors.
- Process creation and management.
- Pipes, signals and inter-process communication.
A shell is an interactive, text-based program that allows users to execute and orchestrate other programs within an operating system by typing commands. It acts as an interface between the user and the kernel.
There are many widely used shell implementations, such as sh, bash, zsh, and fish. Among them, Bash is one of the most common and is often used as a reference due to its POSIX compliance and widespread availability across Unix-like systems. For portability reasons, many shell scripts are written targeting Bash or POSIX sh.
| Feature | Example |
|---|---|
| Single and double quoting | echo 'single quoted $HOME' echo "double quoted $HOME" |
| Variables | export var="42" echo $var |
| Pipelining | echo "foo bar" | tr ' ' \n' |
| Redirections | <, >, >>, << |
| Signals | Ctrl-C, Ctrl-D, Ctrl-\ |
| Builtin commands | echo, cd, pwd, export, unset, env, exit |
| Filename expansion | echo *.md |
Important
There are some limitations to our project:
- Listing commands with
;or&is not possible. They are both treated as invalid tokens. - Filename expansions (
*) target only the current directory and its subdirectories. - There is no brace (
{start..end}), tilde (~), parameter (${parameter}) or arithmetic ($((expression))) expansions. - There is no command (
$(command)) or process (>(command),<(command)) substitution.
-
Clone the repository:
git clone https://github.com/Breno-S/42_minishell.git
-
Move into the project directory:
cd 42_minishell -
Compile the project:
make
-
Run the program:
./minishell
You can now type commands at the prompt and interact with the shell. Press Ctrl-d or type exit to quit.
Some of the main references used during the development of this project:
- Bash Reference Manual
- Shell Command Language (POSIX)
- Shell Code Explained
- Military Grade C/C++ Lexer from Scratch
AI usage disclaimer
During the development of this project, AI tools (such as ChatGPT) were used as a learning aid to clarify concepts related to shell behavior and Unix systems. All architectural decisions, implementations, and debugging were performed by the authors, and no code was copied verbatim from AI-generated sources. The project was developed with the intent of understanding and applying the underlying concepts.