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.
Correct. prepare ; report runs report after prepare regardless of status.
prepare && reportIncorrect. && runs the right command only when the left succeeds.
Incorrect. && runs the right command only when the left succeeds.
prepare || reportIncorrect. || runs the right command only when the left fails.
Incorrect. || runs the right command only when the left fails.
prepare | reportIncorrect. A pipe sends output to another command rather than simply sequencing them.
Incorrect. 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のみ
- 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.