Skip to content

Instantly share code, notes, and snippets.

@dekokun
Created July 6, 2012 07:22
Show Gist options
  • Save dekokun/3058638 to your computer and use it in GitHub Desktop.
Save dekokun/3058638 to your computer and use it in GitHub Desktop.
y/Nを見てコマンド実行
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