This project has been created as part of the 42 curriculum by chguerre, rpinheir
Minishell is a 42 team project where it's main goal is to build a simplified shell. In this project, the goal is to have a working shell with the same behaviour as bash, or at least what is possible to do.
The parsing must get the input from the user and categorize each word into a categorize it.
Per example a pipe '|' is of category PIPE, a command like cat Readme.md are splitted then into two words (by whitespaces)
and categorized 'cat' is a WORD and README.md is also a WORD.
After each word in the input is categorized, we will then build what is called an AST, where everything is linked, the first node of commands have all the arguments
and all the redirections that have been built by the parser.
Per example ``` cat << EOF | grep $USER > user.txt:
Its in this part where we are going to setup the pipes, open files and execute the commands from the AST that was built by the parsing, see how many commands, open each file (fd) and setup the initialisation to have a working redirection and piping to execute properly the command given as input. Within the scope, we manage pipes, redirections, Posix signals like SIGINT (CTRL+C), build history based on recent inputs. There is also a environment cloning where we must manage environment variables, and so also using '$?' to get the exit status of the most recent execution and be able tokens expand variables with character '$'.
This part is where we build commands such as echo or even export, instead of using system programs we program our own following the same behaviour as bash
built-ins.
To build the project:
makeTo run it you can either:
make runor
./minishellFeel free to test with those examples:
ls -lacat << A << Bls | grep .c | wc -lcat README.md | grep "Instructions"cat << eof > here.log | cat here.log | grep "$USER"
USER
$USER
eofAI has been used for debugging purposes only, it has also been used to introduce new notions aside from reading other sources to get a better understanding quicker. Other than that, no AI has been used to do the coding in our place.
- Intro to Parsing & Lexing -- basics for beginners
- Shell parsing tips -- shell parser in detail
- Bash guide on expansion/substituition
- Bash Shell Operation In Depth -- how bash processes a command
- Build a simple shell in C -- shell from scratch
- Code crafters -- non 42 project that is also very close to what we have to do