util: Add abort() which will stop the program immediately
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Jun 2019 11:16:47 +0000 (13:16 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Jun 2019 11:16:47 +0000 (13:16 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.util

index 7379a98..39ad861 100644 (file)
@@ -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() {