1# $FreeBSD: head/tools/regression/bin/sh/builtins/getopts1.0 177498 2008-03-22 14:07:49Z stefanf $
| 1# $FreeBSD: head/tools/regression/bin/sh/builtins/getopts1.0 213883 2010-10-14 23:28:31Z obrien $ 2 3echo '-1-'
|
2set -- -abc 3getopts "ab:" OPTION 4echo ${OPTION} 5
| 4set -- -abc 5getopts "ab:" OPTION 6echo ${OPTION} 7
|
| 8# In this case 'getopts' should realize that we have not provided the 9# required argument for "-b". 10# Note that Solaris 10's (UNIX 03) /usr/xpg4/bin/sh, /bin/sh, and /bin/ksh; 11# ksh93 20090505; pdksh 5.2.14p2; mksh R39c; bash 4.1 PL7; and zsh 4.3.10. 12# all recognize that "b" is missing its argument on the *first* iteration 13# of 'getopts' and do not produce the "a" in $OPTION. 14echo '-2-'
|
6set -- -ab 7getopts "ab:" OPTION 8echo ${OPTION}
| 15set -- -ab 16getopts "ab:" OPTION 17echo ${OPTION}
|
| 18getopts "ab:" OPTION 19echo ${OPTION}
|
9
| 20
|
| 21# The 'shift' is aimed at causing an error. 22echo '-3-'
|
10shift 1 11getopts "ab:" OPTION 12echo ${OPTION}
| 23shift 1 24getopts "ab:" OPTION 25echo ${OPTION}
|