getopts question!!!

is there a better way to check if all args are set???

while getopts h:p:u: opt
do
case "$opt" in
h) host="$OPTARG";;
p) port="$OPTARG";;
u) user="$OPTARG";;
\?)
echo >&2 \
"usage: $0 -h host -p port -u user"
exit 1;;
esac
done

shift `expr $OPTIND - 1`

if test -z "$host"
then
echo >&2 \ "host missing !!!\nusage: $0 -h host -p port -u user"
exit 1
fi

if test -z "$port"
then
echo >&2 \ port missing\n "usage: $0 -h host -p port -u user"
exit 1
fi

if test -z "$user"
then
echo >&2 \ "user missing!!\nusage: $0 -h host -p port -u user"
exit 1
fi

Hi,
According to me best way to check whether the all arguments are set is to have a default value for all the variables(have separate variable for every option) and checking it at the end of the while loop..like this

A_VAL=""
B_VAL=""
while [ $# -ne 0 ]
do
case $1 in
-a)
if [ $2 != "" ]
then
A_VAL="$2"
shift
fi
;;
-b)
if [ "$2" != "" ]
then
B_VAL="$2"
shift
fi
;;
*)
;;
esac
shift
done
if [ "${A_VAL}" = "" ]
then
echo "Throw error"
fi
.....

Thanks
Raghuram