Run false and then echo DONE.
Print DONE even though false fails.
Use a fresh Bash with errexit (set -e) disabled. Wait for the first command to finish before running the next.
Which command list is correct?
Commands separated by a semicolon run in sequence without making the second command conditional on the first command's status.
Detailed explanation
false && echo DONEIncorrect. && suppresses echo when false fails.
false returns one, so the AND list skips echo. That does not satisfy the requirement to print after the failed command.
true || echo DONEIncorrect. true succeeds, so || skips echo.
true returns zero, so the OR list skips echo. This option also replaces the required false with a different command.
false; echo DONECorrect. The semicolon runs echo after false regardless of its status.
With errexit disabled as stated, Bash waits for false to finish and then runs echo. A successful echo can make the list return zero without changing the earlier failure.
false | echo DONEIncorrect. A pipe sends output; false has no output to pass to echo.
This also prints DONE, so output alone does not establish the required sequence. A pipeline does not require echo to start only after false has finished.
Try it yourself
An example you can run in a temporary verification environment.
false; echo DONE
printf 'list status=%s\n' "$?"
(
set -e
false
printf 'not reached\n'
)
printf 'errexit status=%s\n' "$?"Official references
- Official documentation 1
- Official documentation 2
- Official documentation 3
- Official documentation 4
- Official documentation 5
Expected result
DONE
list status=0
errexit status=1Key points
- Semicolon sequencing
- Sequential execution
- Difference from short-circuit lists
Notes
- Environment: A fresh Bash 5.2 process with errexit off. The later subshell alone enables set -e to demonstrate behavior outside the question premise.
- The first example uses the question premise. Only the later subshell enables set -e; the settings of an existing working shell are not changed.
- errexit has exceptions involving conditional tests, AND/OR lists and pipelines. This standalone subshell example is deliberately limited to a simple false outside those contexts.
Foundation review
The same output does not prove the same sequencing
Both the semicolon and pipeline examples print DONE. Assess whether the second command starts after the first has finished, rather than choosing only from the visible word.
Separate a list operator from shell options
A semicolon does not branch on success, but execution still cannot continue after the shell itself exits. The question explicitly disables errexit to keep that separate.
Capture the intended exit status
Immediately after false; echo DONE, $? belongs to echo. Save the status of false before another command replaces it when that earlier result matters.