#!/bin/bash VERSION=$1 # 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. # https://gist.github.com/davejamesmiller/1965569 ask() { local prompt default reply if [ "${2:-}" = "Y" ]; then prompt="Y/n" default=Y elif [ "${2:-}" = "N" ]; then prompt="y/N" default=N else prompt="y/n" default= fi while true; do # Ask the question (not using "read -p" as it uses stderr not stdout) echo -n "$1 [$prompt] " # Read the answer (use /dev/tty in case stdin is redirected from somewhere else) read reply