Created
August 8, 2016 14:40
-
-
Save mnkhouri/0fc367d59ba14fd0d83ae938522b9ec8 to your computer and use it in GitHub Desktop.
shell confirmation/yes-no prompt
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
# From http://stackoverflow.com/a/3232082 | |
confirm () { | |
# call with a prompt string or use a default | |
read -r -p "${1:-Are you sure? [y/N]} " response | |
case $response in | |
[yY][eE][sS]|[yY]) | |
true;; | |
*) | |
false;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment