Created
March 25, 2020 11:03
-
-
Save naviat/bcd648dd4f0f3f30a017f3ebc0c14acc to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# Checks that the given error code is zero. If not, exits the script after printing the given error message. | |
# @param 1 the return code to check. | |
# @param 2 the error message to display in case the given error code is non-zero. | |
# @stdout nothing in case of success, the given error message otherwise. | |
ensureSuccess() { | |
if [[ $1 -ne 0 ]]; then | |
echo | |
echo "Error: $2" | |
echo "ABORTING!" | |
exit 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment