Skip to content

Instantly share code, notes, and snippets.

@barl0g
barl0g / error_exit.sh
Created July 10, 2017 17:54
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!"