From fbe30920d7b79b49376c41cdcc37b2fce74c7ef1 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 19 Nov 2024 09:58:15 +0100 Subject: [PATCH] codes --- sh/log.sh | 8 ++++++++ 1 file changed, 8 insertions(+) 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 }