#
#  yesno   (4/2/88)
#-----------------------------------------------------------------------------
#  yesno prints a prompt and handles a yes/no answer
#
#  Yesno will print a prompt if one is given, and will then accept an
#  answer from the keyboard.  It will set a return code value of zero
#  (no error) if the input starts with a Y (or y), and a return code value
#  of one it the input starts with N (or n).  For any other entries, it will
#  print an error message and ask for another response.
#
#  Notice that this script works without any external programs.  Therefore it
#  is quite fast, even for systems without fast fixed disks.  The first case
#  statement is a way of testing for the presence of an argument without
#  using the external test program.
#-----------------------------------------------------------------------------
while true                                       # loop "forever"
   do
   echo "$1 [y/n]? ^c"                           # print prompt
   read ANSWER                                   # get the response
   case $ANSWER in                               # examine the answer
     [Yy]*) exit 0;;                             # starts with Y or y, return 0
     [Nn]*) exit 1;;                             # starts with N or n, return 1
         *) echo "Please answer with  Y  or  n"  # all else in an error
   esac                                          # end of case statement
done                                             # loop back if not done
