Skip to content

Instantly share code, notes, and snippets.

@mnkhouri
Created August 8, 2016 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnkhouri/0fc367d59ba14fd0d83ae938522b9ec8 to your computer and use it in GitHub Desktop.
Save mnkhouri/0fc367d59ba14fd0d83ae938522b9ec8 to your computer and use it in GitHub Desktop.
shell confirmation/yes-no prompt
# 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