1 2printf -- '-1-\n' 3set -- -abc 4getopts "ab:" OPTION 5printf '%s\n' "${OPTION}" 6 7# In this case 'getopts' should realize that we have not provided the 8# required argument for "-b". 9# Note that Solaris 10's (UNIX 03) /usr/xpg4/bin/sh, /bin/sh, and /bin/ksh; 10# ksh93 20090505; pdksh 5.2.14p2; mksh R39c; bash 4.1 PL7; and zsh 4.3.10. 11# all recognize that "b" is missing its argument on the *first* iteration 12# of 'getopts' and do not produce the "a" in $OPTION. 13printf -- '-2-\n' 14set -- -ab 15getopts "ab:" OPTION 16printf '%s\n' "${OPTION}" 17getopts "ab:" OPTION 3>&2 2>&1 >&3 3>&- 18printf '%s\n' "${OPTION}" 19 20# The 'shift' is aimed at causing an error. 21printf -- '-3-\n' 22shift 1 23getopts "ab:" OPTION 24printf '%s\n' "${OPTION}" 25