Catch errors and return exit status: 1 for warning, 2 for fatal

This commit is contained in:
Matteo Rossini 2020-02-19 21:46:35 +01:00
parent 0749b5944c
commit 968f53ca6c

View file

@ -152,6 +152,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
# Get the current exit-code so that we can check if cleanup is # Get the current exit-code so that we can check if cleanup is
# called in response of a CTRL+C (ie. $?=130) or not. # called in response of a CTRL+C (ie. $?=130) or not.
local lEcode=$? local lEcode=$?
local retval=0
if [ "$CMD" == "info" ];then if [ "$CMD" == "info" ];then
DETAILED_INFO=${DETAILED_INFO:-none} DETAILED_INFO=${DETAILED_INFO:-none}
@ -189,6 +190,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
echo -e "\n\n==============================================================================" echo -e "\n\n=============================================================================="
fi fi
if [ -e $TMPDIR/error.log ]; then if [ -e $TMPDIR/error.log ]; then
retval=1
echo " WARNING! One or more errors occurred while slackpkg was running" echo " WARNING! One or more errors occurred while slackpkg was running"
echo "------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------"
cat $TMPDIR/error.log cat $TMPDIR/error.log
@ -203,6 +205,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
echo "==============================================================================" echo "=============================================================================="
fi fi
if [ -s $TMPDIR/fatal.log ]; then if [ -s $TMPDIR/fatal.log ]; then
retval=2
echo echo
echo "==============================================================================" echo "=============================================================================="
echo echo
@ -218,7 +221,7 @@ if [ "$SLACKPKGPLUS" = "on" ];then
if [ $VERBOSE -lt 3 ];then if [ $VERBOSE -lt 3 ];then
rm -rf $TMPDIR rm -rf $TMPDIR
fi fi
exit exit $retval
} # END function cleanup() } # END function cleanup()
# -- handle the event $1 that occured on packages $SHOWLIST # -- handle the event $1 that occured on packages $SHOWLIST