# for compatibility with the S5R3 /bin/sh getopts builtin
function _getopts # [ arg ] ... optstring name
{
	OPTIND=${OPTIND:-1}
	integer n=$#-1
	eval typeset opstring=['$'$n] name='$'{$#} balance
	typeset -L1 c  d
	shift OPTIND-1
	if	test X"$_arg" = X
	then	if	(($# > 0))
		then	_arg=$1
			shift
		else	return 1
		fi
	fi
	case $_arg in
	--)
		_arg=
		return 1
		;;
	-*)
		c=${_arg#-}
		case $c in
		$opstring)
			d=${opstring#*$c}
			balance=${_arg#*$c}
			if	test X"$balance" = X
			then	if	test X$d = X:
				then	OPTARG=$1
					let OPTIND=OPTIND+2
				else	let OPTIND=OPTIND+1
				fi
				_arg=
			else	if	test X$d = X:
				then	OPTARG=$balance _arg=
					let OPTIND=OPTIND+1
				else	_arg=-$balance
				fi
			fi
			eval $name=$c
			return 0
			;;
		*)	echo $0: bad option
			eval $name=?
			return 1
			;;
		esac
		;;
	*)
		_arg=
		return 1
		;;
	esac
}
alias getopts='_getopts "$@"'
