Skip to content

Instantly share code, notes, and snippets.

@JEM-Mosig
Created July 24, 2019 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JEM-Mosig/d97fcdde7ab2d89b1a05d113f7cd7459 to your computer and use it in GitHub Desktop.
Save JEM-Mosig/d97fcdde7ab2d89b1a05d113f7cd7459 to your computer and use it in GitHub Desktop.
#!/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