I want to parse if the user input is an integer, and force him to do so. First time (iquant) running chkip() works, second time (idays), I immediately get: "Error: Not a number. Please retry." New input works then. I am unsetting ipn before break, so what's the deal?
chkip()
{
ipn=$1
while true;
do
if [[ "$ipn" =~ ^[0-9]+$ ]] ; then
unset ipn
break
else
echo "Error: Not a number. Please retry"
read ipn
fi
done
}
echo "Please enter the name of the Set:"
read ap
echo "How much keys do you want to create [NUMBER]:"
read iquant
chkip $iquant
echo "How often do you want to change the Keys? [DAYS] ?:"
read idays
chkip $idayz
"$1","$iquant", etc), and considerset -uto get an error when you try to use an unset variable.iquantwill contain the old value andipnwill be out of scope.