Minishell is a simple yet robuts shell implementation. It provides a user-friendly interface with essential features, allowing users to interact with the system through a command-line interface.
Minishell displays a prompt when waiting for a new command, making it easy for users to input commands.
The shell maintains a working history, allowing users to access and repeat previously executed commands.
Minishell searches and launches the right executable based on the PATH variable or using a relative or absolute path.
The implementation follows the requirement of not using more than one global variable, ensuring a clean and efficient design. The purpose of the global variable is explained within the code.
The shell handles single quotes ('), preventing interpretation of meta-characters in the quoted sequence. It also handles double quotes (") while allowing the interpretation of the $ (dollar sign) meta-character.
<
redirects input.>
redirects output.<<
reads input until a line containing the specified delimiter, without updating the history.>>
redirects output in append mode.
The shell supports pipes (|), allowing the output of each command in the pipeline to connect to the input of the next command via a pipe.
Minishell handles environment variables ($ followed by a sequence of characters), expanding them to their values.
$?
expands to the exit status of the most recently executed foreground pipeline.
The shell handles the following signals:
- ctrl-C: Displays a new prompt on a new line.
- ctrl-D: Exits the shell.
- ctrl-: Does nothing.
Minishell implements the following built-in commands:
echo
with the option-n
cd
with only a relative or absolute pathpwd
with no optionsexport
with no optionsunset
with no optionsenv
with no options or argumentsexit
with no options
While the readline()
function may cause memory leaks (which are not fixed), the code written by the developer is ensured to be free of memory leaks.
To compile and run Minishell, use the provided Makefile with the following commands:
make
./minishell
This project is licensed under the MIT License. Feel free to use, modify, and distribute the code as per the license terms.