Last active
August 29, 2015 14:08
-
-
Save korovamilk/204a479000b024703091 to your computer and use it in GitHub Desktop.
Shell confirm snippet
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
#!/bin/bash | |
confirm() { | |
echo -n "Continue? (y/n) " | |
read answer | |
case $answer in | |
y|Y|j|J"") return 0 ;; | |
n|N) return 1 ;; | |
*) confirm ;; | |
esac | |
} | |
if confirm | |
then echo ". confirmed ." | |
else echo ". not confirmed ." | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment