Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have several bash scripts I have made, and it's extremely inconvenient when there is a Y/N decision to be made, and if I make a typo or just hit enter it runs/messes up/exits the script. Is there a way to make it so "else" will go to the beginning of the question?
Do you like cheese? [Y/N]:
<read command is here>
If I press enter, or input something else and press enter the scripts messes up and exits instead of saying "invalid option"
I was always taught and believe that break statements like that are bad for the readability of code.
while [ "x$EXIT" != "xtrue" ]; do
echo -n "Make your selection (yes|NO): "
read SELECTION FOOBAR
case $SELECTION in
echo "You said \"Yes\""
echo "I can't allow you to do that."