Skip to content

Instantly share code, notes, and snippets.

@johnloy
Last active August 27, 2021 19:04
Show Gist options
  • Save johnloy/d767687c2884e073a2f760f1b0601fb9 to your computer and use it in GitHub Desktop.
Save johnloy/d767687c2884e073a2f760f1b0601fb9 to your computer and use it in GitHub Desktop.
confirm() {
while true; do
read -p "$1 ([y]/n) " -r
REPLY=${REPLY:-"y"}
if [[ $REPLY =~ ^[Yy]$ ]]; then
return 1
elif [[ $REPLY =~ ^[Nn]$ ]]; then
return 0
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment