Created
July 24, 2019 12:31
-
-
Save JEM-Mosig/d97fcdde7ab2d89b1a05d113f7cd7459 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 | |
# Based on: https://stackoverflow.com/a/25180186 | |
function try() | |
{ | |
[[ $- = *e* ]]; SAVED_OPT_E=$? | |
set +e | |
} | |
function throw() | |
{ | |
exit $1 | |
} | |
function catch() | |
{ | |
export ex_code=$? | |
(( $SAVED_OPT_E )) && set +e | |
return $ex_code | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment