I want to have something which asks the user - "Which environment would you like to load?" - with valid response being either "production" or "development". If an answer is given which doesn't match either it re-asks the question. I want it to set the $production variable so I can run different parts of code later on. This is the closest I could do myself:
read -n1 -p "Which environment would you like to load? [production,development]" doit
case $doit in
production) echo $production=1 ;;
development) echo $production=0 ;;
*) echo ... ;;
esac
It doesn't seem to set the variable when I run it, so I don't know what I am doing wrong. Furthermore how do I make it to re-ask the question when a valid response isn't given?