Created
June 29, 2015 11:19
-
-
Save ViktorStiskala/b958af63e9e8fef2948d to your computer and use it in GitHub Desktop.
Bash catch exception
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 -e | |
err_report() { | |
ERR=$? | |
echo "$1 failed on line $2 ('$3') with error code $ERR" 1>&2 | |
exit $ERR | |
} | |
trap 'err_report "$BASH_SOURCE" "$LINENO" "$BASH_COMMAND"' ERR | |
echo "l" | grep f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment