From b0b2f995c1ab2be2437808fb31d28246a18686a7 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 30 Jun 2012 09:48:41 +0000 Subject: [PATCH] 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. --- functions.util | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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=$@ -- 2.47.3