Skip to content

Instantly share code, notes, and snippets.

@korovamilk
Last active August 29, 2015 14:08
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 korovamilk/204a479000b024703091 to your computer and use it in GitHub Desktop.
Save korovamilk/204a479000b024703091 to your computer and use it in GitHub Desktop.
Shell confirm snippet
#!/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