]> git.ipfire.org Git - people/ms/network.git/commitdiff
assert_check_retval: New function.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Jun 2012 09:48:41 +0000 (09:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 30 Jun 2012 09:48:41 +0000 (09:48 +0000)
This function takes one argument which is an exit code
of a previously called function.
If the exit code equals the assertion exit code, the
script stops immediately.

functions.util

index 6b9daf3530a775c64bc59e608309b053d5188f26..d433aa402e90681e9f2ec3bbc3172af84dabe489 100644 (file)
@@ -209,6 +209,18 @@ function assert() {
        return ${EXIT_OK}
 }
 
+# This function checks, if the given argument is an assert error
+# exit code. If this is the case, the script will halt immediately.
+function assert_check_retval() {
+       local ret=${1}
+
+       if [ ${ret} -eq ${EXIT_ERROR_ASSERT} ]; then
+               exit ${EXIT_ERROR_ASSERT}
+       fi
+
+       return ${ret}
+}
+
 function exec_cmd() {
        local cmd=$@