Run false and then echo DONE.
Print DONE even though false fails.
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.
Incorrect. && suppresses echo when false fails.
true || echo DONEIncorrect. true succeeds, so || skips echo.
Incorrect. true succeeds, so || skips echo.
false; echo DONECorrect. The semicolon runs echo after false regardless of its status.
Correct. The semicolon runs echo after false regardless of its status.
false | echo DONEIncorrect. A pipe sends output; false has no output to pass to echo.
Incorrect. A pipe sends output; false has no output to pass to echo.
Try it yourself
An example you can run in a temporary verification environment.
false; echo DONEExpected result
DONEKey points
- Semicolon sequencing
- Sequential execution
- Difference from short-circuit lists
Notes
- Environment: Bash 5.2
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.