Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created October 31, 2011 21:03
Show Gist options
  • Save thinkerbot/1328948 to your computer and use it in GitHub Desktop.
Save thinkerbot/1328948 to your computer and use it in GitHub Desktop.
Shell prompt example
stty -echo
attempt=0
while [ "$attempt" -lt 3 ]; do
printf "Do you wish to continue? [y/n]: "
read answer
case $answer in
y ) printf "\nOk!\n"; break;;
n ) printf "\nToo bad.\n"; break;;
* ) printf "\nPlease answer y or n.\n";;
esac
attempt=$(($attempt + 1))
done
if [ "$attempt" -eq 3 ]
then printf "Three tries you're out.\n"
fi
stty echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment