improved code quality, few bug fixes

This commit is contained in:
Geoffray Levasseur
2023-08-02 11:36:01 +02:00
parent e16ce485f9
commit cd35f52509
29 changed files with 174 additions and 168 deletions

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------
# Error management functions
# This file is part of the init.sh project
@@ -7,7 +8,7 @@
# The complete license agreement can be obtained at:
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Exit with error
@@ -29,7 +30,7 @@ function die()
unset errorcode
# Put the trigger back (only executed with --keepgoing)
trap "error ${LINENO}" ERR
trap 'error ${LINENO}' ERR
}
export -f die
@@ -73,8 +74,8 @@ trap "error ${LINENO}; backtrace; err_exit" ERR
function err_exit
{
if [[ $KEEPGOING != true ]]; then
if [[ -f $tmpfile ]]; then
rm -f $tmpfile
if [[ -f "$tmpfile" ]]; then
rm -f "$tmpfile"
fi
exit 255
fi
@@ -94,7 +95,7 @@ function backtrace
printf '%15s() %s:%d\n' \
"$func" "${BASH_SOURCE[$i]}" "${BASH_LINENO[ (( $i - 1)) ]}"
fi
let i++ || true
(( i++ )) || true
done
unset func i
echo "=============================="
@@ -120,7 +121,7 @@ noerror()
fi
echo $?
trap "error ${LINENO}" ERR
trap 'error ${LINENO}' ERR
set -o errexit
}
export -f noerror