Run deploy only when build exits with status 0.
Which command list is appropriate?
The && list runs the right command only when the left command succeeds.
Detailed explanation
build || deployIncorrect. || runs deploy when build fails.
Incorrect. || runs deploy when build fails.
build && deployCorrect. deploy runs only when build returns success.
Correct. deploy runs only when build returns success.
build ; deployIncorrect. ; runs deploy regardless of build's status.
Incorrect. ; runs deploy regardless of build's status.
build & deployIncorrect. & starts build in the background and does not wait for its result.
Incorrect. & starts build in the background and does not wait for its result.
Try it yourself
An example you can run in a temporary verification environment.
true && printf deployed; false && printf not-runExpected result
deployedだけを表示Key points
- && on success
- || on failure
- ; unconditionally
Notes
- Environment: GNU Bash 5.2 / Bash組込みtrue・false
- 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.