Skip to content

Instantly share code, notes, and snippets.

@antevens
Created November 22, 2013 17:01
Show Gist options
  • Save antevens/7603277 to your computer and use it in GitHub Desktop.
Save antevens/7603277 to your computer and use it in GitHub Desktop.
Bash exit on failure command
# Exit on failure function
function exit_on_fail {
echo "Last command did not execute successfully but is required to proceed!" >&2
echo "Exiting and rolling back all changes!" >&2
exit 1
}
#USAGE EXAMPLE
sudo yum install puppet || exit_on_fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment