Minishell is a lightweight implementation of POSIX shell designed to provide a minimalistic command-line interface for interacting with an operating system.
Minishell will support the following features:
- Display a user-friendly prompt when waiting for a new command, providing an intuitive user experience.
- Maintain a working command history, allowing users to easily navigate and recall previously executed commands.
- Search and launch the correct executable based on
PATHvariable or relative/absolute paths, offering a smooth command execution process. - Forgo support for unclosed quotes and special characters such as
\(backlash) and;(semicolon), ensuring a cleaner and less error-prone user experience. - Support single quotes
', preventing the shell from interpreting characters within the quoted sequence, allowing users to work with literal strings. - Support double quotes
", preventing the shell from interpreting characters within the quoted sequence, except for the$(dollar sign) for variable expansion. - Provide support for I/O redirections and here documents (
<,>,>>,<<), enabling users to redirect input and output between commands and files. - Handle environment variables, allowing users to set, modify, and retrieve variables as needed.
- Manage
ctrl-C,ctrl-Dandctrl-\signals, ensuring proper behavior similar to that ofbash. - Support special variables, such as
$?, for context-based command behavior. - Support compound commands with a subshell execution
(). - Support command lists with
&&(AND_IF) and||(OR_IF) operators. - Wildcard
*support for current working directory. - Implement built-in commands, including
echo,cd,pwd,export,unset,envandexit, providing essential shell functionality out-of-the-box.
If you don't have gcc or GNU make do these commands:
sudo apt update
sudo apt install build-essentialTo install readline use this command:
tar -xf readline-8.2.tar
make configTo install minishell just run make in the root of the cloned repository.
Minishell's architecture is designed to provide a modular and efficient command-line interface. The project is structured into five distinct modules, each responsible for a specific aspect of Minishell's functionality. These modules work together cohesively to deliver seamless user experience. The following sections outline each module's purpose and functionality.
Inputmodule reads the user input and displays a prompt when waiting for a new command. This module uses thereadlinelibrary, which provides line editing and command history capabilities. Custom signals required for the project are part of this module as well.Lexical Analysismodule generates a list of tokens from the given input to be later used to break it down into an abstract syntax tree.Parserinterprets the string of tokens and builds an AST.Executionunit executes the commands in the processed AST. This module handles built-ins, process creation, and process management. Additionally, it handles input/output redirection and pipelines, command lists, and subshell execution.Exit Statusunit collects the exit status after execution, storing it in a special variable?. It also cleans up the memory that is no longer in use.

