Log program exit

This commit is contained in:
William Hirigoyen 2023-02-17 12:53:31 +01:00
parent 97a98c8df3
commit ff92e3889e

View file

@ -1503,9 +1503,12 @@ main() {
exit ${RC}
}
cleanup_temp_files() {
cleanup() {
# Cleanup tmp files
# shellcheck disable=SC2086,SC2317
rm -f ${files_to_cleanup[@]}
log "$PROGNAME exit."
}
PROGNAME=$(basename "$0")
@ -1530,10 +1533,6 @@ readonly DATEFORMAT
export LANG=C
export LANGUAGE=C
declare -a files_to_cleanup
# shellcheck disable=SC2064
trap cleanup_temp_files 0
# Source configuration file
# shellcheck disable=SC1091
test -f "${CONFIGFILE}" && . "${CONFIGFILE}"
@ -1584,6 +1583,14 @@ while :; do
shift
done
# Keep this after "show_version(); exit 0" which is called by check_versions
# to avoid logging exit twice.
declare -a files_to_cleanup
files_to_cleanup=""
# shellcheck disable=SC2064
trap cleanup EXIT INT TERM
log '-----------------------------------------------'
log "Running $PROGNAME $VERSION..."
# Log config file content