Shell Processing Order#
The logical sequence Bash follows when processing a command.
Tokenization#
The shell reads the input and breaks it into tokens based on metacharacters.
Alias Expansion#
Checks if the first word of the command is an alias and replaces it.
- Bypassing Aliases:
\COMMAND: Using a backslash (eg.\ls) bypasses aliases.command COMMAND: Using thecommandbuilt-in bypasses both aliases and shell functions, ensuring the system binary or built-in is executed.
Expansion#
Expansions are performed in the following order:
- Brace Expansion (
{ }) - Tilde Expansion (
~) - Parameter/Variable Expansion (
$), Command Substitution ($( )), and Arithmetic Expansion ($(( ))) — these are performed at the same time. - Word Splitting
- Pathname Expansion (Wildcards
*,?)
Redirection#
The shell handles I/O redirections (<, >, >>, etc.).
Execution#
The shell searches for the command in this order:
- Functions
- Built-ins
- Executables (searching through
PATH)