Run report after prepare whether prepare succeeds or fails.
Express the sequence on one command line.
Which operator is appropriate?
A semicolon separates commands that run sequentially regardless of the previous exit status. && and || are conditional operators.
Detailed explanation
prepare ; reportCorrect. prepare ; report runs report after prepare regardless of status.
prepare && reportIncorrect. && runs the right command only when the left succeeds.
prepare || reportIncorrect. || runs the right command only when the left fails.
prepare | reportIncorrect. A pipe sends output to another command rather than simply sequencing them.
Try it yourself
An example you can run in a temporary verification environment.
false; printf 'reported\n'Expected result
reportedKey points
- ; is unconditional sequence
- && runs on success
- || runs on failure
Notes
- Environment: Bash 5.x / shell builtinのみ
- Use disposable shell sessions and harmless commands for experiments.
- Shell behavior can depend on Bash options and distribution defaults.
Foundation review
Place the operation
A semicolon expresses sequencing without a condition, unlike the short-circuit operators.
Check the side effect
Use harmless commands that return both zero and nonzero statuses when testing a list.