Minishell is a collaborative project from 42 School designed to teach students how to create a fundamental shell program using the C programming language. This project involves implementing key shell functionalities such as handling redirections and pipes, expanding environment variables, and supporting several built-in commands. These built-ins include cd
for navigating directories, echo
for displaying messages, env
for listing environment variables, exit
for terminating the shell, export
for managing environment variables, pwd
for printing the current directory, and unset
for removing variables from the environment.
125%
Clone the repository and compile:
cd minishell && make
cd minishell && make bonus
To run the program:
./minishell
When the shell starts, a prompt will appear, allowing you to enter commands to be executed.
Minishell includes essential shell functionalities, such as:
- Prompt Display: Displays a prompt, awaiting commands from the user.
- Built-in Commands: Implements
echo
,cd
,pwd
,export
,unset
,env
, andexit
functionalities. - Executable Resolution: Locates and executes programs using
$PATH
or specified relative/absolute paths. - Redirections and Pipes: Supports operators like
|
,<
,>
,<<
, and>>
, mimicking Bash behavior. - Environment Variable Handling: Processes
$
variables and evaluates$?
for the status of the last command. - Signal Management: Responds to
Ctrl+C
,Ctrl+D
, andCtrl+\
with behavior similar to Bash. - Command History Navigation: Allows users to browse through their command history using the arrow keys.
The project additionally offers bonus features to enhance the shell experience:
- Advanced Line Editing: Provides features like text cutting, copying, and pasting, along with word-by-word navigation via readline.
- Logical Operators: Enables the use of
&&
and||
for command chaining. - Wildcard Expansion (
*
): Includes support for expanding wildcard patterns. - Exit Code Display: Shows the current exit code in the Minishell prompt.
- Current Directory Display: Displays the current working directory in the prompt.