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

@@ -28,6 +28,7 @@ backupdist()
exit 11
fi
local file=
for file in $@; do
local tmstmp=$(stdtime)
if [[ - L ${file} ]]; then
@@ -50,7 +51,9 @@ backupdist()
else
prnt W "backupdist(): $file n'existe pas, rien à faire."
fi
unset tmstmp
done
unset file
}
export -f backupdist
@@ -72,6 +75,7 @@ installfile()
die 7
fi
local arg=
for arg in $@; do
if [[ -f $MYPATH/repo/hosts/$HOSTNAME/$arg ]]; then
filelist="$filelist $MYPATH/repo/hosts/$HOSTNAME/$arg"
@@ -82,15 +86,19 @@ installfile()
filelist="$filelist $arg"
fi
done
unset arg
# Empty to just obtain the target which is the last element of the list
for i in $filelist; do
local file=
for file in $filelist; do
:
done
if [[ ! $i == /* ]]; then
if [[ ! $file == /* ]]; then
prnt E "installfile(): Target must be on the root filesystem and full path must be provided."
die 13
fi
unset file
if [[ -d $(dirname $i) ]]; then
prnt I "Création du répertoire $(dirname $i) d'accueil..."
mkdir -pv $(dirname $i)