Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Troubleshooting a error output at the end of a script.

This...

# We now request that the user restarts their server...
read -e -p "Restart your server now to complete the install (y/n)? " rsn
    case $rsn in
        [Yy]* ) break;;
        [Nn]* ) exit;
    esac
done

Produces...

/dev/fd/63: line 446: break: only meaningful in a `for', `while', or `until' loop
/dev/fd/63: line 449: syntax error near unexpected token `done'
/dev/fd/63: line 449: `done'

Any ideas on an alternate to break;; in this instance?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Do nothing :) That is, either use for example true or : instead of break or remove the line altogether.

A better solution would be to actually use a while loop:

while true
do
    [your code]
done

This way the break does what you want, and you fix a bug: What happens if rsn doesn't start with [YyNn]?

share|improve this answer
    
Thanks! Great explanation of the subject. Tossed while true; do in there and everything runs smooth. –  d3c0y Mar 6 at 8:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.