Minishell is a 42-school project that aims to introduce us to the world of shells by recoding our mini-bash, a program that can parse, execute, and launch executables along with some built-in commands.
readline, rl_clear_history, rl_on_new_line, rl_replace_line, rl_redisplay, add_history, printf, malloc, free, write, access, open, read, close, fork, waitpid, signal, kill, exit, getcwd, chdir, execve, dup2, pipe, perror.
- input: Readline output
- output: tokenized linked list
- the objective of this step is to split the readline output using tokens (defined macros)
- used tokens: WORD, REDIRECTION, PIPE, AND, SEMI, PARENTHESIS
- input: tokenized linked list
- output:
- in case of no syntax error: same tokenized linked list.
- in case of a syntax error: printed error type.
- the objective of this step is to check all possible command syntax errors (if you have a doubt about an error take bash as a reference).
- input: tokenized linked list
- output: commands linked list
- we can split this step into 2 sub-steps
- handling redirections (input, output, append, heredoc).
- add command to the linked list with their file descriptors (in and out).
- input: commands linked list
- if everything went okay in the past steps we have 2 different cases to communicate between the commands (processes):
- if there are
$N$ commands we initialize$N-1$ pipes to communicate between the processes we create. - In another case, if there’s some kind of redirection, it takes the priority
- if there are
- the only step left is to verify if the command is available or not there are two ways to handle it depending on the command itself
- relative path
- absolute path
- in this part, the commands are ready to be executed
- shell maintains an environment that includes a set of variables defined by a name, a user initialization, and system initialization.
- sources that can help you like us:
- Tokenization is a way of separating a sentence into smaller units called tokens,
- Sources that can help you like us:
- It analyses the syntactical structure and checks if the given input is in the correct syntax of the programming language or not.