Bash Command Line Expansion: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 8: | Line 8: | ||
=Overview= | =Overview= | ||
=Process= | |||
Each line read by bash from command line is interpreted as a [[Bash_Concepts#Pipeline|pipeline]]: a sequence of commands separated by the [[Bash_Concepts#.7C|pipe character (|)]]. | Each line read by bash from command line is interpreted as a [[Bash_Concepts#Pipeline|pipeline]]: a sequence of commands separated by the [[Bash_Concepts#.7C|pipe character (|)]]. | ||
Line 14: | Line 16: | ||
Then the result is parsed into tokens by using [[Bash_Concepts#Metacharacters|metacharacters]] as separators. | Then the result is parsed into tokens by using [[Bash_Concepts#Metacharacters|metacharacters]] as separators. | ||
==Command Line Expansion== | |||
The token are scanned to perform ''command line expansion'', which are the following operations, performed in order: | The token are scanned to perform ''command line expansion'', which are the following operations, performed in order: | ||
===Brace Expansion=== | |||
===Tilde Expansion=== | |||
===Parameter and Variable Expansion=== | |||
===Arithmetic Expansion=== | |||
===Command Substitution=== | |||
===Word Splitting=== | |||
===Pathname Expansion=== | |||
===Process Substitution=== | |||
==Quote Removal== | |||
After all command line expansion specified above are performed, bash proceeds with ''quote removal'': it removes from the command line single quotation marks, double quotation marks and backslashes that are not a result of an expansion. | After all command line expansion specified above are performed, bash proceeds with ''quote removal'': it removes from the command line single quotation marks, double quotation marks and backslashes that are not a result of an expansion. |
Revision as of 00:16, 9 September 2017
External
Internal
Overview
Process
Each line read by bash from command line is interpreted as a pipeline: a sequence of commands separated by the pipe character (|).
Command processing starts by checking the first word of the command against an alias list, and if a match is found, the alias is replaced.
Then the result is parsed into tokens by using metacharacters as separators.
Command Line Expansion
The token are scanned to perform command line expansion, which are the following operations, performed in order:
Brace Expansion
Tilde Expansion
Parameter and Variable Expansion
Arithmetic Expansion
Command Substitution
Word Splitting
Pathname Expansion
Process Substitution
Quote Removal
After all command line expansion specified above are performed, bash proceeds with quote removal: it removes from the command line single quotation marks, double quotation marks and backslashes that are not a result of an expansion.