freebsd-nq/bin/sh/tests/builtins/getopts6.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

8 lines
125 B
Plaintext

# $FreeBSD$
set -- -x -y
getopts :x var || echo "First getopts bad: $?"
getopts :x var
r=$?
[ r != 0 ] && [ "$OPTIND" = 3 ]