]> git.ipfire.org Git - people/ms/network.git/commitdiff
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 7379a9887de812acf0eb812ef2cb2b0b7d0091e4..39ad8613b6e4419c5ef97e86c900e63ac9d75383 100644 (file)
@@ -469,14 +469,27 @@ assert() {
        local assertion="$@"
 
        if ! ${assertion}; then
        local assertion="$@"
 
        if ! ${assertion}; then
-               error_log "Assertion '${assertion}' failed."
                backtrace
                backtrace
-               exit ${EXIT_ERROR_ASSERT}
+
+               # End the program here
+               abort "Assertion failed: ${assertion}"
        fi
 
        return ${EXIT_OK}
 }
 
        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() {
 # 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() {