Algorithm:
- The program reads commands of any length in parts using a buffer.
- Parses the input data and forms an array of tokens from them.
- Performs syntax validation. If the syntax is correct, go to step 4. Otherwise, it reports an error and returns to step 1.
- Builds a command tree based on the array.
- Executes commands from the tree, handling errors.
- Goes to step 1 while waiting for the next command.
The program processes the following special sequences: < > >> | || && & ; ( ) " ' \ # $SHELL $HOME $USER $EUID
It consists of 3 main modules:- shellexec (see below)
- parse (see below)
- main
It also uses following auxiliary modules:
- colors (to learn more about it, see the module README.md)
- strarr (to learn more about it, see the module README.md)
- strarr_iter (to learn more about it, see the module README.md)
- shelltree (to learn more about it, see the module README.md)
The function executes shell commands of tree and returns exit status; 'bg_pp' is a pipe for background process to remove zombies; 'emerg' is a function that is called in son after fork if execution is failed.
`char ** parse(char **strarr);`
The function parses strarr for shell.
`ShTree * st_build(char **arr);`
The function creates and returns ShTree by parsed array.