mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
lib.sh: simplify err()
Rely once again on err_, but still explicitly add an exit just below, in case I made a mistake one day. err() is essentially a trap that triggers in case I mess up an error function, so that it doesn't reliably exit. So, the idea is that everything calls err(), and err() is almost never modified, or modified very carefully. If error exits were ever broken, the result could be quite unpredictable, so lbmk has very strict error handling, and great care is taken to ensure that it does reliably exit. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+5
-11
@@ -185,19 +185,13 @@ err()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
$real_err "$@" || printf \
|
$real_err "$@" || err_ "Error function '$real_err' *returned* 1"
|
||||||
"WARNING: Err function '%s' *returned* 1. Will exit 1 anyway\n" \
|
err_ "Error function '$real_err' didn't exit"
|
||||||
"$real_err" 1>&2
|
exit 1 # just in case!
|
||||||
printf "WARNING: Err function '%s' didn't exit. Will exit 1 anyway\n" \
|
|
||||||
"$real_err" 1>&2
|
|
||||||
exit 1
|
|
||||||
) || xbmk_err_val=1 # otherwise, it wrongly did exit 0, not exit 1
|
) || xbmk_err_val=1 # otherwise, it wrongly did exit 0, not exit 1
|
||||||
|
|
||||||
[ $xbmk_err_val -eq 0 ] && printf \
|
[ $xbmk_err_val -eq 0 ] && err_ "Error function '$real_err' did exit 0"
|
||||||
"WARNING: Err function '%s' did exit 0. Will exit 1 anyway.\n" \
|
exit 1 # just in case!
|
||||||
"$real_err" 1>&2
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err_()
|
err_()
|
||||||
|
|||||||
Reference in New Issue
Block a user