Created
November 22, 2013 17:01
-
-
Save antevens/7603277 to your computer and use it in GitHub Desktop.
Bash exit on failure command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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