From ceb6add8ab50a24dc9bb675aecf44ccbcf75696a Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Mon, 20 May 2024 17:39:56 +0300 Subject: [PATCH] Fix clean up to return correct exist status https://github.com/virtualmin/virtualmin-install/issues/108 --- slib.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/slib.sh b/slib.sh index 828b847..c663149 100644 --- a/slib.sh +++ b/slib.sh @@ -8,6 +8,7 @@ # Licensed under the BSD 3 clause license #------------------------------------------------------------------------------ cleanup () { + exit_code=$1 stty echo # Make super duper sure we reap all the spinners # This is ridiculous, and I still don't know why spinners stick around. @@ -24,22 +25,19 @@ cleanup () { fi fi - if [ "$1" != "EXIT" ]; then + if [ "$exit_code" -ne 0 ]; then echo fi - cleanup() { - : - } - exit 1 + exit $exit_code } # This tries to catch any exit, whether normal or forced (e.g. Ctrl-C) if [ "${INTERACTIVE_MODE}" != "off" ]; then - trap 'cleanup INT' INT - trap 'cleanup QUIT' QUIT - trap 'cleanup TERM' TERM - trap 'cleanup EXIT' EXIT + trap 'cleanup 2' INT + trap 'cleanup 3' QUIT + trap 'cleanup 15' TERM + trap 'cleanup 0' EXIT fi # scolors - Color constants