I'm learning Bash and I am trying to solve an exercise.
The exercise consists of selecting the first and last names, from a menu list. However, if the name is not in the list then set manual input.
But I'm a little bit confused because I don't when an option is select how to go to the second menu, without select option Quit (I try add Break in any option but doesn't work).
For the manual input y try read the input from the user but doesn't see working any suggestion?
How I can terminate the loop when I get the name and last name? Because when I get both, I get to the same loop.
echo -e "Choose your name Exercise #2 \n"
PS3='Please enter your name from the List: '
options=("Elvis" "John" "Mark" "Manual Input" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Option 1")
;;
"Option 2")
;;
"Option 3")
;;
"Option 4")
echo "Sorry your Name is not in the List Give your name"
read -e -p "Whats your name: " MANUALINPUT
;;
"Quit")
break
;;
esac
echo "Hello $opt Next Step is Select your Lastname "
done
PS4='Please enter your last name from the List: '
options2=("Smith" "Brown" "Miller" "Manual Input" "Quit")
select opt2 in "${options2[@]}"
do
case $opt2 in
"Option 1")
;;
"Option 2")
;;
"Option 3")
;;
"Option 4")
echo "Sorry your Name is not in the List Give your name"
read -e -p "Whats your name: " MANUALINPUT
;;
"Quit")
break
;;
esac
clear
echo "Welcome $opt $opt2"
done