-# Parse command line options
-
-# "unset" option variables to make sure they weren't accidentally
-# exported
-debug=""
-
-# If you add new commands be sure to change the wildcards below to make
-# sure they are unambiguous (i.e. only match one possible long option)
-# Be sure to show at least one instance of the full long option name to
-# document what the long option is canonically called.
-while test $# -gt 0 ; do
- case z$1 in
- z-D | z--debug | z--d* )
- debug="t"
- shift
- ;;
- z-h | z--help | z--h* )
- echo "${usage}" 1>&2
- exit 1
- ;;
- z-- )
- shift
- break
- ;;
- z-* )
- echo "${progname}: ${bq}${1}${eq} is not a valid option." 1>&2
- echo "" 1>&2
- echo "${usage}" 1>&2
- exit 1
- ;;
- * )
- break
- ;;
+# Parse command line arguments.
+# Make sure that all wildcarded options are long enough to be unambiguous.
+# It's a good idea to document the full long option name in each case.
+# Long options which take arguments will need a `*' appended to the
+# canonical name to match the value appended after the `=' character.
+while : ; do
+ case $# in 0) break ;; esac
+ case "$1" in
+ -D | --debug | --d* )
+ debug=t
+ shift
+ ;;
+ -h | --help | --h* )
+ echo "$usage" 1>&2
+ exit 0
+ ;;
+ -v | --version | --v* )
+ echo "texi2dvi version $version" 1>&2
+ exit 0
+ ;;
+ -- ) # Stop option processing
+ shift
+ break
+ ;;
+ -* )
+ case "$1" in
+ --*=* ) arg=`echo "$1" | sed -e 's/=.*//'` ;;
+ * ) arg="$1" ;;
+ esac
+ exec 1>&2
+ echo "$progname: unknown or ambiguous option $bq$arg$eq"
+ echo "$progname: Use $bq--help$eq for a list of options."
+ exit 1
+ ;;
+ * )
+ break
+ ;;