Minishell is a simple shell implementation that mimics the behavior of the GNU Bash shell. It supports built-in commands, redirections, pipes, signal handling, and an interactive command-line interface.
- Features
- Built-in Commands
- Redirections
- Pipes
- Signal Handling
- Environment Variables
- Installation
- Authors
✔️ Display a prompt when waiting for a new command 🖥️
✔️ Maintain a working history of commands
✔️ Search and launch the correct executable (via PATH, relative, or absolute path)
✔️ Avoid using more than one global variable for signal handling
✔️ Correctly handle unclosed quotes and special characters
✔️ Handle:
- Single quotes (
'): Prevents meta-character interpretation - Double quotes (
"): Prevents meta-character interpretation except for$
✔️ Implement redirections:
<Redirect input>Redirect output<<Read input until a specified delimiter appears (without history update)>>Append output to a file
✔️ Implement pipes (|) for command chaining
✔️ Support environment variables ($VAR) and exit status ($?)
✔️ Handle signals:
Ctrl+C: Displays a new prompt on a new lineCtrl+D: Exits the shellCtrl+\: Does nothing
✔️ Implement the following built-in commands:
echo(with-noption)cd(supports relative/absolute paths)pwdexportunsetenvexit
✔️ Memory-leak free 🔥
| Command | Description |
|---|---|
echo |
Prints text to the terminal. Supports the -n option (no newline). |
cd |
Changes the current directory (supports relative and absolute paths). |
pwd |
Prints the current working directory. |
export |
Sets environment variables. |
unset |
Unsets environment variables. |
env |
Displays the environment variables. |
exit |
Exits the shell. |
| Symbol | Description |
|---|---|
< |
Redirects input from a file. |
> |
Redirects output to a file. |
<< |
Reads input until a line containing a specified delimiter appears. |
>> |
Redirects output to a file (append mode). |
| Symbol | Description |
|---|---|
| |
Pipes the output of one command into the input of another. |
| Keybinding | Behavior |
|---|---|
Ctrl+C |
Displays a new prompt on a new line. |
Ctrl+D |
Exits the shell. |
Ctrl+\ |
Does nothing. |
| Variable | Description |
|---|---|
$VAR |
Expands to the value of the specified environment variable. |
$? |
Expands to the exit status of the last executed command. |
To install and run Minishell, follow these steps:
-
Clone the repository:
git clone https://github.com/mfaria-p/minishell.git
-
Navigate to the project directory:
cd minishell -
Build the project:
make
-
Run Minishell:
./minishell
GNU Bash manual
readline: libreadline-dev
Enjoy your experience with our Minishell! 🚀🎉
