]> git.saurik.com Git - apple/shell_cmds.git/blame - sh/tests/builtins/getopts1.0
shell_cmds-216.60.1.tar.gz
[apple/shell_cmds.git] / sh / tests / builtins / getopts1.0
CommitLineData
deb63bfb 1# $FreeBSD: head/bin/sh/tests/builtins/getopts1.0 297752 2016-04-09 16:06:13Z jilles $
71aad674
A
2
3printf -- '-1-\n'
4set -- -abc
5getopts "ab:" OPTION
deb63bfb 6printf '%s\n' "${OPTION}"
71aad674
A
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.
14printf -- '-2-\n'
15set -- -ab
16getopts "ab:" OPTION
deb63bfb 17printf '%s\n' "${OPTION}"
71aad674 18getopts "ab:" OPTION 3>&2 2>&1 >&3 3>&-
deb63bfb 19printf '%s\n' "${OPTION}"
71aad674
A
20
21# The 'shift' is aimed at causing an error.
22printf -- '-3-\n'
23shift 1
24getopts "ab:" OPTION
deb63bfb 25printf '%s\n' "${OPTION}"