code cleanup: force local var before calling a for loop, make sure it's unset when no longer needed

This commit is contained in:
fatalerrors
2021-10-06 10:37:13 +02:00
parent c0b1bf1665
commit 1ac3ec303c
9 changed files with 65 additions and 16 deletions

View File

@@ -25,6 +25,7 @@ read_commandline()
local want_logfile=false
local want_conffile=false
local opt=
for opt in $@; do
case $opt in
"-h"|"--help")
@@ -105,12 +106,15 @@ read_commandline()
;;
esac
done
unset opt
# If those var are true at that point, something is wrong
if [[ $want_logfile == true ]] || [[ $want_module == true ]] ||
[[ $want_conffile == true ]]; then
syntax_error
fi
unset want_conffile want_logfile want_module
}
export -f read_commandline
@@ -150,6 +154,8 @@ load_autoconf()
if [[ -n $SYS_CODE && -e $prefix/$SYS_DIST-$SYS_CODE-$SYS_ARCH.conf.sh ]]; then
. $prefix/$SYS_DIST-$SYS_CODE-$SYS_ARCH.conf.sh
fi
unset prefix
}
export -f load_autoconf
@@ -162,6 +168,7 @@ export -f load_autoconf
load_configuration()
{
if [[ -n $CONFFILES ]]; then
local f=
for f in $CONFFILES; do
prnt I "Chargement de $f spécifié manuellement."
if [[ -s $f ]]; then
@@ -171,6 +178,7 @@ load_configuration()
die 6 --force
fi
done
unset f
else
prnt I "Chargement de la configuration..."
if [[ -e $MYPATH/conf/$HOSTNAME.conf.sh ]]; then