Skip to content

Instantly share code, notes, and snippets.

@gammazero
Created April 20, 2021 18:12
Show Gist options
  • Save gammazero/410739a23a2666eefc4bc3ef31a7fdb8 to your computer and use it in GitHub Desktop.
Save gammazero/410739a23a2666eefc4bc3ef31a7fdb8 to your computer and use it in GitHub Desktop.
function ask_yes_no() {
local prompt="$1"
while true; do
read -p "$prompt [y/n]?" yn
case "$yn" in
[Yy]* ) return 0;;
[Nn]* ) return 1;;
* ) echo "Please answer y or n";;
esac
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment