Contributors: Kais, Alaë, Julien, Theo
42sh, is the compilation of projects minishell, 21sh and 42sh. It consists of reproducing the behaviour of bash in C during 5 months with 4 team members. This project gave us the opportunity to learn all the moving parts of a shell (lexer, parser, execution, job control, readline, variables, etc) and perfect our knowledge in the bash scripting language. Along with the main part we made some features and bonus.
The execution pipeline of the shell starts with the readline module wich handles line editing, all terminal interactions and signal handling while the user is entering input, it then passes the user input to the lexer that scans the command line yielding a list of tokens that are then passed to the parser for syntatic analysis. After input validation by the parser, an abstract syntax tree is generated and passed to the interpretation module that evaluates the newly created tree, when a tree node is not bypassed by a logical operator ('&&' or '||'), the corresponding command pipeline is passed to the expansion module for variable substitution, parameters expansion, filename expansion and pattern matching. The execution submodule then sets the appropriate environment variables, redirections, pipes and job control (if required) before launching each command in the pipeline. The shell optionally waits for the executed pipeline to be finished before navigating further in the tree.
- History
- fc builtins
- ! expansions
- History File
- Ctrl+R
- Autocompletions
- Contextual and dynamic
- Quoting
"
,'
,\
- Tilde and additional parameter
- ${var:para}
- Globbing
*
,!
,[]
,?
- Alias
- Customization of the prompt
- Hash table for retrieving binaries in $PATH
- Builtins are POSIX compliant
- set/unset
- export
- exit
- fc
- type
- alias
- fg/bg
- hash
- cd
info | status | str |
---|---|---|
malloc | MEMERR | ? |
error | -2 | ? |
error | -1 | ? |
OK | 0 | cmd |
Ctrl+D | 1 | NULL |
Ctrl+C | 2 | NULL |
keys | description |
---|---|
^ v |
Browse the history |
Shift+< Shift+> |
Move one word |
end/ctrl+e | Line forward |
end/ctrl+a | Line backward |
tab | Autocompletion |
ctrl+l | Clear the terminal |
ctrl+d | Exit the shell |
ctrl+r | Search a command |
ctrl+v | Visual mode |
ctrl+p | Paste |
ctrl+x | Cut |
ctrl+y | Copy |
nb | mode | description |
---|---|---|
2 | MODEFILE | quand stdin est fermé |
1 | INTERACTIVE | appele readline quand la commande n'est pas complete |
0 | NONINTERACTIVE | traite la commande tel quelle |