From 9532462fe04658d728ecbf263b586111f73fe2b2 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 3 Jun 2019 13:16:47 +0200 Subject: [PATCH] util: Add abort() which will stop the program immediately Signed-off-by: Michael Tremer --- src/functions/functions.util | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/functions/functions.util b/src/functions/functions.util index 7379a988..39ad8613 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -469,14 +469,27 @@ assert() { local assertion="$@" if ! ${assertion}; then - error_log "Assertion '${assertion}' failed." backtrace - exit ${EXIT_ERROR_ASSERT} + + # End the program here + abort "Assertion failed: ${assertion}" fi return ${EXIT_OK} } +# Ends the program immediately without cleaning up +abort() { + local msg="$@" + + # Print message + if isset msg; then + log ERROR "${msg}" + fi + + exit ${EXIT_ERROR_ASSERT} +} + # This function checks, if the given argument is an assert error # exit code. If this is the case, the script will halt immediately. assert_check_retval() { -- 2.39.2