This repository contains the implementation of the Minishell project. The project involves building a basic shell that mimics the behavior of the popular bash shell. It covers fundamental concepts such as process creation, input/output redirection, and signal handling.
The goal of the Minishell project is to help understand how a shell works by building a minimal version of bash. For that, we need to learn how to handle user input, execute commands, manage processes, and work with file descriptors. This project is a great opportunity to get familiar with the Unix programming environment and its system calls.
-
Shell Basics:
- Display a prompt while waiting for a new command.
- Parse and execute commands based on the PATH environment variable or using relative/absolute paths.
- Implemented a simple history of executed commands.
-
Redirections:
<
: Redirect input from a file.>
: Redirect output to a file, overwriting if the file exists.>>
: Append output to a file.<<
: Here-document. Read input until a given delimiter is encountered.
-
Pipes:
- Implemented the
|
character to pipe the output of one command into the input of another.
- Implemented the
-
Environment Variables:
- Handle expansion of environment variables using $ followed by a sequence of characters.
- Support
$?
to get the exit status of the most recently executed foreground pipeline.
-
Signal Handling:
Ctrl+C
: Display a new prompt on a new line.Ctrl+D
: Exit the shell.Ctrl+\
: Do nothing.
-
Built-in Commands:
echo
with-n
optioncd
with relative or absolute pathpwd
with no optionsexport
with no optionsunset
with no optionsenv
with no options or argumentsexit
with no options
- Logical Operators:
- Implement
&&
and||
with support for parentheses for precedence.
- Implement
- Wildcards:
- Implement wildcard
*
expansion in the current working directory.
- Implement wildcard
- Clone repository
git clone [email protected]:mjorgecruz/42_minishell.git
- Go inside project directory and run
make
cd 42_minishell make
- Run
./minishell
./minishell
- Jorge Cruz
- Luis Carvalho