Держи :) Копирайт мой
# Check entered answer on presence "yes" or "no" - another answers
# is prohibited
#
# Input: $1 (string) - user answer
# $2 (string) - warning sign.
# When parameter set to "warn", script claims about missed input
# Output: $_isavalid (int) - 0, when answer is not valid
# 1, when answer is valid
check_yesno()
{
local _check _warn
_warn=${2:-no}
# At start name claimed as NOT valid!
_isavalid=0
# Check on presence any data, passed as answer
if [ ${#1} -eq 0 ]; then
if [ $_warn = "warn" ]; then
echo "There is no defaults, please answer \"Yes\" or \"No\""
fi
return
fi
# Check name through specified regexp
regexp="^([Yy][Ee][Ss])$|^([Nn][Oo])$|^[Yy]$|^[Nn]$"
_check=`echo $1 | grep -v -E -e "$regexp"`
if [ ${#_check} -ne 0 ]; then
return
fi
_isavalid=1
}