Skip to content

Instantly share code, notes, and snippets.

@atika
atika / ask.sh
Last active August 29, 2015 14:08
This is a general-purpose function to ask Yes/No questions in Bash, either with or without a default answer.
#!/bin/bash
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
# http://djm.me/ask
while true; do
if [ "${2:-}" = "Y" ]; then