I\'m prompting questions in a bash script like this:
optionsAudits=(\"Yep\" \"Nope\")
echo \"Include audits?\"
select opt in \"${optionsAudits[@]}\"; do
Updated answer:
echo "Include audits? 1) Yep, 2) Nope"
read ans
case $ans in
Yep|1 ) echo "yes"; includeAudits=true; v=1 ;;
Nope|2 ) echo "no"; includeAudits=false; v=2 ;;
"" ) echo "default - yes"; includeAudits=true; v=1 ;;
* ) echo "Whats that?"; exit ;;
esac
This accepts either "Yep"
or "1"
or "enter"
to select yes, and accepts "Nope"
or "2"
for no, and throws away anything else. It also sets v to 1 or 2 depending on whether the user wanted yes or no.