Created
May 29, 2015 06:39
-
-
Save okisanjp/ac42b874d53985b49fa2 to your computer and use it in GitHub Desktop.
readで入力待ちの時、whileと組み合わせて想定文字以外のときにエラーを表示する ref: http://qiita.com/okisanjp/items/47698db1de28b5836ca5
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
echo -n "Are you sure you want to exit the server? [y/n] > " | |
while : | |
do | |
read INPUT | |
case "$INPUT" in | |
"y" ) kill $SERVER_PID | |
echo "Stopped WEBRick" | |
break ;; | |
"n" ) echo "Canceled." | |
break ;; | |
* ) echo "[y/n] で入力してね!" ;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment