Skip to content

Instantly share code, notes, and snippets.

@korovamilk
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save korovamilk/204a479000b024703091 to your computer and use it in GitHub Desktop.

Select an option

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