Created
January 29, 2016 17:45
-
-
Save pjvandehaar/a84aa1e2a9be5fb5b911 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/bash | |
set -euo pipefail | |
error() { | |
local parent_lineno="$1" | |
local message="$2" | |
local code="${3:-1}" | |
if [[ -n "$message" ]] ; then | |
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}" | |
else | |
echo "Error on or near line ${parent_lineno}; exiting with status ${code}" | |
fi | |
touch FAILED | |
exit "${code}" | |
} | |
trap 'error ${LINENO}' ERR | |
echo hi | |
eco woot | |
echo wat | |
touch SUCCEEDED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment