ifand terminate your script. But doing that for every command in the script would make your script less readable and more prone to bugs.
Shells provide a clean solution for this use case: you can set a script-level option to stop the script execution if any command you invoke from the script exits with a non-zero status. You do that in bash using
and in zsh using
So your script would essentially look like this:
zsh also has a
#!/bin/bash set -e make make test make push
err_returnoption that can be set to make a function return (as opposed to terminating the whole script) when a command invoked by a function fails.