Minimal bash-like shell written in C.
This project involves writing a simple shell in C with basic functionalities. The project can be divided into 6 key parts:
Divide the input commands into lexical units called "tokens" and assign a type for each token.
Analyse the tokens and check if the input command conforms with the defined grammar.
This step includes opening files, redirecting input/output, processing heredocs, expanding environement variables, and removing quotes
Search for the binary in the directories of the PATH variables, or if a path is provided check if the executable can be accessed
Implement the following built-ins: cd, pwd, echo, export, unset, exit
Handle interruption signals just like bash does : ◦ ctrl-C displays a new prompt on a new line. ◦ ctrl-D exits the shell. ◦ ctrl-\ does nothing (instead of the default behaviour of quitting and generating a core dump).
Key features include:
- A working history.
- Searching and launching the right executable (based on the PATH variable or using a relative or an absolute path).
- Handling single (') and double (") quotes.
- Input/output redirections:
- < redirects input.
- > redirects output in truncate (overwrite) mode.
- << [delimiter] : reads the input until a line containing the delimiter is seen.
- >> redirects output in append mode.
- Handling pipes (| character). The output of each command in the pipeline is connected to the input of the next command via a pipe.
- Expanding environment variables (i.e
echo $varprints the values stored in the variablevar)
Minishell requires the readline library in order to function. You can install it using your favorite package manager.
To build the debug version of the minishell, cd into the project's root directory and run:
make
For the release version, run:
make release
To clean build files, run:
make clean