From: Michael Tremer Date: Sat, 30 Jun 2012 09:48:41 +0000 (+0000) Subject: assert_check_retval: New function. X-Git-Tag: 005~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0b2f995c1ab2be2437808fb31d28246a18686a7;p=network.git assert_check_retval: New function. 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. --- diff --git a/functions.util b/functions.util index 6b9daf35..d433aa40 100644 --- a/functions.util +++ b/functions.util @@ -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=$@