I have defined a function as below.
no input- exit
input 'n'-> exit
input 'y'-> continue to next step
input other than 'y' or 'n' -> retry for 3 times & still wrong input-> exit
I am not able to achieve the last retry part. can someone help?
my_func()
{
read -p "Still want to continue (y/n)? : " userin
userin=${userin,,}
if [ -z "$userin" ];then
echo "No input"
exit 1
elif [ $userin == "n" ]; then
exit 1
elif [ $userin == "y" ]; then
echo "Next step starting
return
else
echo "You entered $userin - give proper input(y/n)"
fi
}