Catch errors and return exit status 1 if they occur

Thanks to mcandre on LQ for the suggestion.
This commit is contained in:
Robby Workman 2019-01-16 00:15:57 -06:00
parent a9c7e7d4c7
commit c7216fb599

View file

@ -7,8 +7,10 @@
# Clean-up tmp and lock files
#
function cleanup() {
local retval=0
[ "$SPINNING" = "off" ] || tput cnorm
if [ -e $TMPDIR/error.log ]; then
retval=1
echo -e "
\n==============================================================================
WARNING! WARNING! WARNING! WARNING! WARNING!
@ -24,7 +26,7 @@ One or more errors occurred while slackpkg was running:
rm $CACHEPATH/$NAMEPKG &>/dev/null
fi
( rm -f /var/lock/slackpkg.$$ && rm -rf $TMPDIR ) &>/dev/null
exit
exit ${retval}
}
trap 'cleanup' 2 14 15 # trap CTRL+C and kill