Created
March 12, 2014 14:23
-
-
Save katoy/9507953 to your computer and use it in GitHub Desktop.
yes/no を聞く bash スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# bash で yes/no を聞く。 | |
# | |
# See http://yuki.silk.to/2006/04/000161.html | |
# http://usaturn.net/memo/shell_tech_yesorno.html | |
function yes_no() { | |
echo "-------------------------------------------" | |
echo "よろしいですか?(yes/no)" | |
echo -n " => " | |
read ans | |
# echo "-------------------------------------------" | |
case ${ans} in | |
[Yy]|[Yy][Ee][Ss]) | |
echo "yes が選択されました。" | |
return 0 ;; | |
[Nn]|[Nn][Oo]) | |
echo "no が選択されました。" | |
return 1 ;; | |
*) | |
yes_no ;; | |
esac | |
} | |
yes_no | |
ans=$? | |
echo "#--- yes_no() return ${ans}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment