1
0
Fork 0

Modularité avec les versions de matchScript sous forme de liste

This commit is contained in:
trotFunky 2018-05-05 19:04:03 +02:00
parent 8354cebf4a
commit dedb4bc31b

View file

@ -28,6 +28,21 @@ function parameterTest { # Test si le paramètre $1 est égal à la valeur $2 et
fi
}
function multiTest { # Vérifie si $1 fait parti des éléments de $2
if [ ! $# -eq 2 ]; then
exit
fi
for toTest in ${!2}; do
if [ "$1" = "$toTest" ]; then
echo "0"
exit
fi
done
exit
}
configFile=""$( dirname "${BASH_SOURCE[0]}" )"/config.txt"
if [ ! -e $configFile ]; then
@ -35,6 +50,8 @@ if [ ! -e $configFile ]; then
exit
fi
matchScriptVersions=("0" "1" "2" "99")
### COLOR CHANGE
@ -121,12 +138,19 @@ if [ $changeMatchScript != 'n' ]; then
confirmMatchVersion=" "
newMatchVersion=" "
while [ "$newMatchVersion" != "0" -a "$newMatchVersion" != "1" -a "$newMatchVersion" != "99" ]; do
echo -n "Choose a valid version (0/1/99): "
while [ ! $(multiTest "$newMatchVersion" matchScriptVersions[@]) ]; do
echo -n "Choose a valid version ("
for i in ${matchScriptVersions[@]};do
echo -n "$i"
if [ ! "$i" = "${matchScriptVersions[$(expr ${#matchScriptVersions[@]} - 1)]}" ]; then
echo -n "/"
fi
done
echo -n "): "
read newMatchVersion
done
while [ "$confirmMatchVersion" != "0" -a "$confirmMatchVersion" != "1" -a "$confirmMatchVersion" != "99" ]; do
while [ ! $(multiTest "$confirmMatchVersion" matchScriptVersions[@] ) ]; do
echo -n "Please confirm your selection: "
read confirmMatchVersion
done