diff --git a/sh/log.sh b/sh/log.sh index e91c3ca..34e986f 100644 --- a/sh/log.sh +++ b/sh/log.sh @@ -16,14 +16,22 @@ sh_log_debug() { } sh_log_error() { + local code="${1}" + shift + [ -n "${code}" ] || sh_log_fatal 1 "No error code" if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_ERROR}" ]; then echo "[ERROR]" "${@}" >&2 + return "${code}" fi } sh_log_fatal() { + local code="${1}" + shift + [ -n "${code}" ] || sh_log_fatal 1 "No error code" if [ "${SH_LOG_LEVEL}" -ge "${SH_LOG_LEVEL_FATAL}" ]; then echo "[FATAL]" "${@}" >&2 + exit "${code}" fi }