Skip to content

Instantly share code, notes, and snippets.

@p3lim
p3lim / ask.sh
Created October 20, 2016 19:31
Bash: General-purpose Yes/No prompt function ("ask")
# 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.
ask() {
# http://djm.me/ask
local prompt default REPLY
while true; do