b7e565fcb4a6b7a79dc468c51301fb0f6348aacd
[dragonfly.git] / tools / regression / bin / sh / builtins / getopts1.0
1 # $FreeBSD: src/tools/regression/bin/sh/builtins/getopts1.0,v 1.3 2012/01/06 23:20:33 jilles Exp $
2
3 printf -- '-1-\n'
4 set -- -abc
5 getopts "ab:" OPTION
6 echo ${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.
14 printf -- '-2-\n'
15 set -- -ab
16 getopts "ab:" OPTION
17 echo ${OPTION}
18 getopts "ab:" OPTION
19 echo ${OPTION}
20
21 # The 'shift' is aimed at causing an error.
22 printf -- '-3-\n'
23 shift 1
24 getopts "ab:" OPTION
25 echo ${OPTION}