Skip to content

Instantly share code, notes, and snippets.

@barl0g
Created July 10, 2017 17:54
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 barl0g/d79599e381897a1eae931690ca779428 to your computer and use it in GitHub Desktop.
Save barl0g/d79599e381897a1eae931690ca779428 to your computer and use it in GitHub Desktop.
error_exit
https://stackoverflow.com/questions/24597818/exit-with-error-message-in-bash-oneline
function error_exit {
echo "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
exit "${2:-1}" ## Return a code specified by $2 or 1 by default.
}
[[ $TRESHOLD =~ ^[0-9]+$ ]] || error_exit "Threshold must be an integer value!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment