#!/bin/sh
#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
# $Header:tailor.query.sh 12.0$ 
# $ACIS:tailor.query.sh 12.0$ 
# $Source: /ibm/acis/usr/src/etc/tailor/RCS/tailor.query.sh,v $ 

# tailor.query
# usage:x=`tailor.query "question to ask" help_file default_answer all_answers....`
Query="$1"
shift
Help=$1
shift
Default=$1
shift
while :
do
	Ans=
	found=no
	echo -n "$Query [$Default]: " > /dev/tty
	read Ans junk
	if [ ! "$Ans" ]
	then
		Ans=$Default
	fi
	for i in "$@"
	do
		case "$Ans" in
		$i)	found=yes
		       ;;
		esac
	done
	case "$found$Ans" in
	"yes?"|no*)	(case "$Ans" in
		'?')	cat $Help
			;;
		*)	echo "Reply must be one of:"
			echo "$*"
			;;
		esac)	> /dev/tty
		;;
	yes*)	break
		;;
	esac
done
echo $Ans
