Table of Contents
This is the first group project of the 42 core curriculum. The objective of this project is to create a simple bash-like shell. There were specific Project specifications, like only being allowed to use a few low-level functions and POSIX system calls. If you want to know more about the requirements, take a look at the Subject PDF. This project was done in collaboration with Florian Bindereif
The Project was mainly tested on macOS, but it should work on all UNIX/LINUX based systems.
To run the Minishell, you need to install the readline library first, which can be done like this:
brew install readline
Or
apt-get install libreadline-dev
- Clone the repo
git clone https://github.com/42sin/minishell.git && cd minishell
- Change the readline path inside of the Makefile, you can see your path with
brew info readline
-I/usr/local/opt/readline/include -L/usr/local/opt/readline/lib
- Compile the project
make
- Run the minishell
./minishell
You can use the minishell as you would use any other Shell to execute commands. We handled a lot of unnecessary things that were not specifially required by the Subject, which you can read more about in Features
Here is an example of a basic command using some of the control operators.
This is a more advanced example where you can see the implementation of Here Documents, the variable used as a delimiter isn't expanded but the ones used inside of the Here Document are expanded.
- History of previously entered commands
- Search and launch the right executable (based on the PATH variable, using a relative or an absolute path)
- Environment variables ($ followed by a sequence of characters) expand to their values
- Wildcards *
- Ctrl-C, Ctrl-D, and Ctrl-\ behave like in bash
’
(single quotes - prevent from interpreting meta-characters in quoted sequence)"
(double quotes - prevent from interpreting meta-characters in quoted sequence except for $)$?
expands to the last exit status|
Output of a command is connected to the input of the next Command&&
and||
with parenthesis for priorities
echo
with-n
cd
(relative or absolute path,~
for HOME)pwd
export
without arguments or with a new environment variable to be setunset
env
exit [exit_status]
[n] < file
Redirecting Input[n] << limiter
Here Documents with environment variable handling[n] > file
Redirecting Output[n] >> file
Appending Redirected Output
Distributed under the MIT License. See LICENSE
for more information.