#!/bin/sh
PATH=/bin:/usr/bin

# default is no -x, and -c12
xflag=
count=12

if t=`getopt c:x $*`
then
    :
else
    echo usage: $0 \[-c count\] \[-x\] \[name ...\] >&2
    exit 1
fi

set -- $t

while test $# -gt 0 && test "x$1" != x--
do
    case "$1" in
	-c)
	    shift
	    count="$1"
	    ;;
	-x)
	    xflag=1
	    ;;
    esac
    shift
done
shift

echo Command-line options:
echo '   ' count is $count
if test $xflag
then
    echo '   ' x flag is on
else
    echo '   ' x flag is off
fi

if test $# -gt 0
then
    for i
    do
	echo arg $i
    done
else
    echo and there are no further arguments.
fi
