From d14c5d117b9d25cb25f6b97ae67c6791334497ce Mon Sep 17 00:00:00 2001 From: Arjan H Date: Fri, 10 Mar 2023 18:12:51 +0100 Subject: [PATCH] Make it clearer when an error occurs in install script --- install | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/install b/install index ffd736d..d2a5db5 100755 --- a/install +++ b/install @@ -6,7 +6,12 @@ # Install with this command from a Linux machine (only tested with Debian and Ubuntu): # curl -sSL https://raw.githubusercontent.com/hakwerk/labca/master/install | bash -set -e +set -eEuo pipefail +trap 'err_report $? $LINENO' INT TERM ERR + +err_report() { + msg_fatal "return code $1 on line $2 in $(basename $0)" $1 +} # # Variables / Constants @@ -85,7 +90,7 @@ msg_fatal() { local msg="$1" echo -e "\\n ${COL_LIGHT_RED}Error: ${msg}${COL_NC}\\n" echo "[`date "${logTimeFormat}"`] [FATAL] ${msg}" >> $installLog - exit 1 + exit ${2:-1} } #