Starting Minishell
To start Minishell, simply run the executable:Understanding the Prompt
The Minishell prompt shows your username and current directory:Command Line Syntax
Minishell accepts commands in the following format:Command History
Minishell uses the GNU Readline library, providing powerful command history features:- Up Arrow (↑): Navigate to previous commands
- Down Arrow (↓): Navigate to next commands in history
- Ctrl+R: Search through command history (reverse search)
All commands you enter are automatically saved to history, allowing you to easily recall and re-execute previous commands.
Quote Handling
Minishell supports both single and double quotes with different behaviors:Single Quotes (')
Single quotes preserve the literal value of all characters within the quotes:
Double Quotes (")
Double quotes preserve the literal value of most characters, but allow variable expansion:
Special Characters
Minishell recognizes several special characters:| Character | Meaning | Example | ||
|---|---|---|---|---|
$ | Variable expansion | echo $HOME | ||
| ` | ` | Pipe operator | `ls | grep txt` |
< | Input redirection | cat < file.txt | ||
> | Output redirection | echo hi > out.txt | ||
>> | Append redirection | echo hi >> out.txt | ||
<< | Heredoc | cat << EOF |
Variable Expansion
Minishell expands environment variables prefixed with$:
Variable expansion does not occur inside single quotes, but does occur inside double quotes.
Common Usage Patterns
Combining Commands
Use pipes to chain multiple commands:Redirecting Output
Save command output to a file:Reading from Files
Provide file content as input:Exiting Minishell
There are two ways to exit Minishell:When you exit, Minishell displays a red “Exit” message to confirm termination.
Signal Handling
Minishell handles common signals:- Ctrl+C (SIGINT): Interrupts the current command and displays a new prompt
- Ctrl+\ (SIGQUIT): Ignored (does nothing)
- Ctrl+D (EOF): Exits the shell when entered on an empty line
Error Handling
When errors occur, Minishell provides helpful messages:$? and can be checked: