Skip to content

Instantly share code, notes, and snippets.

@hisamekms
Last active August 29, 2015 14:07
Show Gist options
  • Save hisamekms/5b754078d532b38f1a5b to your computer and use it in GitHub Desktop.
Save hisamekms/5b754078d532b38f1a5b to your computer and use it in GitHub Desktop.
Yes/Noで答えるプロンプト ref: http://qiita.com/hisamekms/items/b8b07a64facff399c721
#!/bin/zsh
while true; do
read Answer\?'Do you like coffee? [Y/n]'
case $Answer in
'' | [Yy]* )
echo Yes!
break;
;;
[Nn]* )
echo No!
break;
;;
* )
echo Please answer YES or NO.
;;
esac
done
#!/bin/bash
while true; do
read -p 'Do you like coffee? [Y/n]' Answer
case $Answer in
'' | [Yy]* )
echo Yes!
break;
;;
[Nn]* )
echo No!
break;
;;
* )
echo Please answer YES or NO.
esac
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment