Created
July 6, 2012 07:22
-
-
Save dekokun/3058638 to your computer and use it in GitHub Desktop.
y/Nを見てコマンド実行
This file contains hidden or 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
function yes_no { | |
msg=$1 | |
while : | |
do | |
echo -n "${msg} y/N: " | |
read ans | |
case $ans in | |
[yY]) return 0 ;; | |
[nN]) return 1 ;; | |
esac | |
done | |
} | |
command="hogehoge" | |
yes_no "exec command:$command " | |
if [ $? -eq 0 ];then | |
eval $command | |
echo finished | |
else | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment