bash: Simple Command Expansion
1
1 3.7.1 Simple Command Expansion
1 ------------------------------
1
1 When a simple command is executed, the shell performs the following
1 expansions, assignments, and redirections, from left to right.
1
1 1. The words that the parser has marked as variable assignments (those
1 preceding the command name) and redirections are saved for later
1 processing.
1
1 2. The words that are not variable assignments or redirections are
1 expanded (⇒Shell Expansions). If any words remain after
1 expansion, the first word is taken to be the name of the command
1 and the remaining words are the arguments.
1
11 3. Redirections are performed as described above (⇒
Redirections).
1
1 4. The text after the '=' in each variable assignment undergoes tilde
1 expansion, parameter expansion, command substitution, arithmetic
1 expansion, and quote removal before being assigned to the variable.
1
1 If no command name results, the variable assignments affect the
1 current shell environment. Otherwise, the variables are added to the
1 environment of the executed command and do not affect the current shell
1 environment. If any of the assignments attempts to assign a value to a
1 readonly variable, an error occurs, and the command exits with a
1 non-zero status.
1
1 If no command name results, redirections are performed, but do not
1 affect the current shell environment. A redirection error causes the
1 command to exit with a non-zero status.
1
1 If there is a command name left after expansion, execution proceeds
1 as described below. Otherwise, the command exits. If one of the
1 expansions contained a command substitution, the exit status of the
1 command is the exit status of the last command substitution performed.
1 If there were no command substitutions, the command exits with a status
1 of zero.
1