freebsd-nq/bin/sh/tests/builtins/getopts7.0
Jilles Tjoelker 6e76445cf7 sh: Don't discard getopts state on unknown option or missing argument.
When getopts finds an invalid option or a missing option-argument, it should
not reset its state and should set OPTIND as normal. This is an old ash bug
that was fixed long ago in dash. Our behaviour now matches most other
shells.
2014-05-10 17:42:21 +00:00

7 lines
76 B
Plaintext

# $FreeBSD$
set -- -x
getopts :x: var
r=$?
[ r != 0 ] && [ "$OPTIND" = 2 ]