getopts1.0 revision 265773
1177498Sstefanf# $FreeBSD: head/bin/sh/tests/builtins/getopts1.0 265773 2014-05-09 13:32:36Z jilles $ 2213883Sobrien 3229742Sjillesprintf -- '-1-\n' 4177498Sstefanfset -- -abc 5177498Sstefanfgetopts "ab:" OPTION 6177498Sstefanfecho ${OPTION} 7177498Sstefanf 8213883Sobrien# In this case 'getopts' should realize that we have not provided the 9213883Sobrien# required argument for "-b". 10213883Sobrien# Note that Solaris 10's (UNIX 03) /usr/xpg4/bin/sh, /bin/sh, and /bin/ksh; 11213883Sobrien# ksh93 20090505; pdksh 5.2.14p2; mksh R39c; bash 4.1 PL7; and zsh 4.3.10. 12213883Sobrien# all recognize that "b" is missing its argument on the *first* iteration 13213883Sobrien# of 'getopts' and do not produce the "a" in $OPTION. 14229742Sjillesprintf -- '-2-\n' 15177498Sstefanfset -- -ab 16177498Sstefanfgetopts "ab:" OPTION 17177498Sstefanfecho ${OPTION} 18265773Sjillesgetopts "ab:" OPTION 3>&2 2>&1 >&3 3>&- 19213883Sobrienecho ${OPTION} 20177498Sstefanf 21213883Sobrien# The 'shift' is aimed at causing an error. 22229742Sjillesprintf -- '-3-\n' 23177498Sstefanfshift 1 24177498Sstefanfgetopts "ab:" OPTION 25177498Sstefanfecho ${OPTION} 26