references:
bash_manual
bash_source_code
-
Structure
- Init
- Input
- Lexer
- Parser
- Expand
- Special Parameters: One of
@,*,#,?,-,$,!, or0 - A Variables name
- A variable name surrounded by
{and} - An arithmetic expansion, surrounded by
(and) - A command substitution, surrounded by
((and)) - Positional Parameters
$0,$1,$n,$#,$@and$*
- Special Parameters: One of
- Ast
- Execution
- Builtins
-
Line editing
- Simple and advanced line editing
- Edit the line where the cursor is positionned
- Move cursor left or right
- Up and Down arrows to navigate in the history
- Enter Insert mode with
alt+iand exit it withalt+i - Copy and paste with
alt+Calt+v - Move word per word left or right
alt+LEFTalt+RIGHT - Go to beginning or end of a line.
homeend - Move to top or bottom line.
alt+UPalt+DOWN - Waits for the end of a quote or double quote.
- ctrl+D and ctrl+C usable when editing a line or in multi-line.
- Multiline line editing
-
Builtins with their POSIX options (For more info type
helponce in the shell)-
cd|chdir -
echo -
exit -
env -
setenv -
unsetenv -
unset -
export -
history -
pwd
-
-
Exec
- Executing commands stored in path with their parameters
- Error handling and return value handling
- Redirections handled :
>,<,<<and>> - Pipes
| - Logical operators
&&and|| - Backquotes "‘" (TODO)
- Ihibitors """ (double quote), "’" (simple quote) et "" (backslash).
-
; -
\nhandling where\ncan be used as a;. Example:ls \n ls==ls ; ls
-
Prompt
- Multi line editing with
\,'and" - History handles the multi-line editing
- Multi line editing with
-
Shell
- This shell proposes multiple options to enhance user experience
-
hThis option will display help for all options as described here -
vVerbose mode -
dDebug mode (Enables the logger). A log file will be created where the binary exists. This option requires a log level from 0 to 7 -
tTest mode. This mode will test the moduleXwithYparameter as follows :-t X Y. Can be used with modulesenvastparserlexerast -
cCommand. Use this option to send a command to the shell and get it's output -
CColor. Use this option to enable color in the shell -
lDisables the termcaps. This is a debug option and not a feature ! To be used lightly
-
Signals
- We kill all childs when we get a signal that kills the program so no zombie process is left behind
-
Autocompletion
- Dynamic autocompletion
- Autocompletes binaries from
PATH - Autocompletes files and paths
- Autorefreshing with a new input from the user: modification of the list of possibility. TODO WIP
-
Environ
- Local Variables are available
- Normal environment is used when the shell is started
- Uses the
=syntax (VAR=VALUE) - Default env is given when 42sh is started with env -i (TODO to be customized)
- Message to warn the User when 42sh is started without an env
-
Bonuses
- Heredocs "<<".
- File descriptors aggregation
-
History
- A menu is printed when the history fil is to big
- The history is printed in the log when exiting the program
- History research
ctrl+R.
have fun. Programming can be a lot of fun, and if you’re not generally having fun, you’re not in the right mindset to be programming. Tired or unhappy programmers make mistakes, and debugging code tends to take much longer than writing it correctly in the first place! Often you can save yourself some time by going to bed, getting a good night’s sleep, and coming back to a problem in the morning.