42 C3 Minishell - rciak/zz_42_shared_notes GitHub Wiki
Design Phase
The Design phase is after the learning / reading phase and just before the implementation phase. It is about thinking about stuff like the following and drafting accordingly.
- Which structures are suitable for the task(s)?
- Which functions are needed? Describe their prototypes along with
- What is the function's purpose / What is it doing?
- What information are the Variables delivering and/or receiving?
Preparation: Some stuff from the Bash Reference Manual
The following stems (at least for most parts) from the Annotated Bash Manual.
Main Steps
The following is created from the Section 3.1.1 Shell Operation and 3.7.1 Simple Command expansion.
When a simple command is executed, the shell performs the following expansions, assign- ments, and redirections, from left to right, in the following order.
- redirections are saved for later processing.
- words that are not redirections are expanded
(Note: The text does not say anything here if expansion take place or not when the word after the redirection operator is a redirection; Actually it depends, e.g. if it is a heredoc redirection or not.) - Redirections are performed as described above.
- (Variable assignments are done only in connection with the export builtin) The text after the ‘=’ in each variable assignment undergoes tilde expansion, parameter expansion, and quote removal before being assigned to the variable.
If no command name results, redirections are performed, but do not affect the current
shell environment.
(In e.g. > outfile.txt
after the execution of that command, the redirecation shall no longer be active
and the open filedescriptor to outfile.txt should be closed.)
A redirection error causes the command to exit with a non-zero status.
If there is a command name left after expansion, execution proceeds as described below.
Otherwise, the command exits.
the command exits with a status of zero.