mardi 25 juillet 2017

Another way to use a variable readed and passed as argument inside a function

The script works but is there any way to get the same result without using "tmp" varaible ?

Thanks

function ask_version () {
while true ; do
 echo -e "Give the version of" $1
local tmp=$2
read -r tmp

  if [[ ! $tmp =~ ^[0-9]$ ]] ; then
     echo -e "Please respect number format"
  elif [[ $tmp -ne $t ]] ; then
   echo -e "It is not the true number"
  else
    return 0
  fi
done
}

ask_version "APP1" "APP1VERSION"
ask_version "APP2" "APP2VERSION"

Aucun commentaire:

Enregistrer un commentaire