summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-05-04 16:23:11 +0100
committerLeah Rowe <leah@libreboot.org>2025-05-04 16:23:11 +0100
commit4020fb432805cfc7ebd243b0873574f25182ba40 (patch)
treefd4c1ac15c27b8992c1200dff05dc40add1c2e0f
parentb51846da6dead8f138858dcdb3da0b78d713e580 (diff)
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>
-rw-r--r--include/lib.sh16
1 files changed, 5 insertions, 11 deletions
diff --git a/include/lib.sh b/include/lib.sh
index 1bfe2060..e7b5bd3d 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -185,19 +185,13 @@ err()
fi
(
- $real_err "$@" || printf \
- "WARNING: Err function '%s' *returned* 1. Will exit 1 anyway\n" \
- "$real_err" 1>&2
- printf "WARNING: Err function '%s' didn't exit. Will exit 1 anyway\n" \
- "$real_err" 1>&2
- exit 1
+ $real_err "$@" || err_ "Error function '$real_err' *returned* 1"
+ err_ "Error function '$real_err' didn't exit"
+ exit 1 # just in case!
) || xbmk_err_val=1 # otherwise, it wrongly did exit 0, not exit 1
- [ $xbmk_err_val -eq 0 ] && printf \
- "WARNING: Err function '%s' did exit 0. Will exit 1 anyway.\n" \
- "$real_err" 1>&2
-
- exit 1
+ [ $xbmk_err_val -eq 0 ] && err_ "Error function '$real_err' did exit 0"
+ exit 1 # just in case!
}
err_()