#!/bin/sh -u # # $0 prompt_text # # Print the prompt text and wait for a Yes or No answer. # Script exits 0 (good) for Yes, 1 (bad) for No. # Unrecognized input causes the prompt to be re-issued. # # -IAN! idallen@ncf.ca July 2001 export PATH=/bin:/usr/bin umask 022 # Be generous about command line syntax - if more than 1 arg, # assume all args are part of the prompt (user forgot quotes?). # case "$#" in 0) echo 1>&2 "$0: No arguments; using empty prompt" prompt="" ;; *) prompt="$*" ;; esac # Keep prompting forever until we get a clear Yes or No. # while : ; do echo 1>&2 " " echo 1>&2 "$prompt" echo " Yes or No? " | tr -d '\n' 1>&2 read answer case "$answer" in [yY] | [yY][eE][sS] ) exit 0 ;; # good status [nN] | [nN][oO] ) exit 1 ;; # bad status esac echo 1>&2 "$0: Unrecognized response '$answer'" done