Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

A sequential command list in Bash is a sequence of one or more pipelines separated by the semicolon control operator (;) or a newline character (\n). It enforces synchronous, left-to-right execution, meaning the shell waits until the current command terminates before executing the subsequent command.

Syntax

Inline execution using the semicolon operator:
command1 ; command2 ; command3
Multiline execution using newline characters:
command1
command2
command3

Execution Mechanics

  • Pre-Execution Parsing: Bash parses the entire line or block of code before any execution begins. If a syntax error exists anywhere in the sequential list (e.g., echo a ; if), the shell throws an error during the parsing phase, and no commands in the list are executed.
  • Synchronous Blocking: During execution, the shell waits for the current pipeline to finish before executing the next pipeline in the sequence. The execution context depends on the command type: external commands are executed in forked child processes, while shell builtins (e.g., cd, echo, read) and shell functions are executed directly within the current shell process without forking.
  • Unconditional Evaluation: Unlike the AND (&&) and OR (||) control operators, the semicolon operator does not perform short-circuit evaluation. command2 will execute regardless of whether command1 returns a zero (success) or non-zero (failure) exit status, provided the shell’s errexit option (set -e) is not enabled.
  • Backgrounding: If a command is terminated by the asynchronous control operator (&) instead of ;, the shell executes that specific command in the background and immediately proceeds to the next command in the list without waiting.

Exit Status

The return status of a sequential command list is strictly the exit status of the last command executed in the sequence. If preceding commands fail but the final command succeeds, the exit status of the entire list is 0.
false ; false ; true
echo $? # Outputs: 0

Grouping Sequential Lists

Sequential lists can be grouped to apply redirections to the entire sequence or to manipulate the execution context. Current Shell Execution (Compound Command): Enclosing the list in braces executes the sequence within the current shell environment. A trailing semicolon or newline is strictly required before the closing brace.
{ command1 ; command2 ; command3 ; }
Subshell Execution: Enclosing the list in parentheses forks a subshell to execute the sequence. Variable assignments, directory changes, or environment modifications within the subshell do not propagate to the parent shell.
( command1 ; command2 ; command3 )
Master Bash with Deep Grasping Methodology!Learn More