Basically the process is this.
After parsing the current line, (i.e. splitting into tokens,) the first token needs to be run. The shell will try to run it first as a shell keyword or an alias. If this is not possible, then it will parse further and finally execute the new first token as a built-in or external command.
Here is the sequence again -
tokenizing - split into tokens
If the first token is a shell keyword, then it is marked as a keyword and processed futher as per the syntax of that keyword.
If the first token is an alias, then it is expanded.
brace expansion
tilde expansion
parameter expansion
command substitution
arithmetic substitution
word splitting
command lookup: function, built-in command, executable file
Refererences -
Bash Cookbook
by Albing et al
Portable Shell Scripting
by Seebach
After parsing the current line, (i.e. splitting into tokens,) the first token needs to be run. The shell will try to run it first as a shell keyword or an alias. If this is not possible, then it will parse further and finally execute the new first token as a built-in or external command.
Here is the sequence again -
tokenizing - split into tokens
If the first token is a shell keyword, then it is marked as a keyword and processed futher as per the syntax of that keyword.
If the first token is an alias, then it is expanded.
brace expansion
tilde expansion
parameter expansion
command substitution
arithmetic substitution
word splitting
command lookup: function, built-in command, executable file
Refererences -
Bash Cookbook
by Albing et al
Portable Shell Scripting
by Seebach
No comments:
Post a Comment