I am wondering how to get the value from a case wildcard? I have an array that generates a menu for me. I then have a case that determines which option is chosen. The last part of the case statement is the wildcard value. I am looking to get the value used for the wildcard.
Here is the code that I am using:
menu=()
menu+=('Option 1')
menu+=('Option 2')
menu+=('Option 3')
menu+=('Option 4')
menu+=('Quit')
echo "What would you like to install?"
echo " "
select opt in "${menu[@]}"
do
case $opt in
'Option 1' )
echo "Doing Option 1"
;;
'Option 2' )
echo "Doing Option 2"
;;
'Option 3' )
echo "Doing Option 3"
;;
'Option 4' )
echo "Doing Option 4"
;;
'Quit' )
echo "Quitting installations"
exit;
;;
* )
echo "Invalid input: ${opt}"
;;
esac
done
In the above, the "Invalid input" value is always empty. I can enter "foobar" as the option and it does not show. I have also change the variable to just $opt
but it still doesn't print out.