diff --git a/tpromptuser.sh b/tpromptuser.sh index 0cefd89..ca3bb86 100755 --- a/tpromptuser.sh +++ b/tpromptuser.sh @@ -19,7 +19,7 @@ # single character answers to the prompt. If this list is empty, # then any response to the prompt is accepted. -# $Id: tpromptuser.sh,v 1.101 2010/10/07 18:26:58 tundra Exp $ +# $Id: tpromptuser.sh,v 1.102 2010/10/07 18:34:13 tundra Exp $ ##### # Constants @@ -36,16 +36,21 @@ # # PromptDefault Response (If user just hits Enter)Legal Answers -foo="Would you like to foo?${DL}Y${DL}" # Empty last field means accept anything +# Examples + +foo="Would you like to foo?${DL}Y${DL}" # Empty last field means accept anything bar="Would you like to bar?${DL}\!${DL}y Y n N" -baz="Would you like to baz?${DL}n${DL}yes Yes no No " -bat="Would you like to bat?${DL}""${DL}yes Yes no No " +baz="Would you like to baz?${DL}n${DL}yes Yes no No" +bat="Would you like to bat?${DL}${DL}yes Yes no No " # Display the records for purposes of this example only echo "Before: foo->$foo bar->$bar baz->$baz bat->$bat" + +# ---------- Nothing Should Change Below This Line ---------- # + ##### # Actual Prompting Logic ##### @@ -65,7 +70,7 @@ DONE=False - while [ $DONE = False ] + while [ _$DONE = _False ] do read -p "${prompt} (Default: ${default}) " ANS @@ -73,7 +78,7 @@ # We're done if the user took the default OR if the "Legal # Answers" field is empty (which means we accept anything) - if [ _$ANS = _ ] || [ _$answers = _ ] + if [ _$ANS = _ ] || [ _"$answers" = _ ] then DONE=True