#! /bin/bash 

# Asks user to type "y"/"yes" or "n"/"no", keeps insisting until 
# he does.  Then return "yes" or "no".

while [[ 1 ]]; do
  printf "proceed? [y/n]:" 1>&2
  ans="`head -n 1`"
  if [[ ( "${ans}"  == "y" ) || ( "${ans}"  == "yes" ) ]]; then
    echo "yes"
    exit 0
  elif [[ ( "${ans}"  == "n" ) || ( "${ans}"  == "no" ) ]]; then
    echo "no"
    exit 0
  else
    echo "** please say yes or no." 1>&2
  fi
done
