]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/getopts.tests
Bash-4.4 patch 19
[thirdparty/bash.git] / tests / getopts.tests
1 # getopts tests
2 # this should fail
3 getopts
4 echo $?
5 getopts opts
6 echo $?
7
8 # maybe someday we will have a ksh93-like -a argument to set the name
9 # used in error messages, but not yet
10 getopts -a opts name
11
12 ${THIS_SH} ./getopts1.sub -a -b bval one two three
13 # make sure getopts works when there are more than 9 positional parameters
14 ${THIS_SH} ./getopts1.sub -a -b bval one two three four five six seven eight nine ten eleven twelve
15 ${THIS_SH} ./getopts1.sub -a -b
16
17 ${THIS_SH} ./getopts2.sub -ad -c cval three four five
18
19 ${THIS_SH} ./getopts3.sub
20
21 # make sure that `-b bval' and `-bbval' are equivalent
22 ${THIS_SH} ./getopts4.sub -a -b bval one two three
23 ${THIS_SH} ./getopts4.sub -a -bbval one two three
24 # this tests `silent' error reporting
25 ${THIS_SH} ./getopts4.sub -a -b
26 ${THIS_SH} ./getopts4.sub -a -c
27
28 # make sure that `--' can be used to end the list of options
29 ${THIS_SH} ./getopts4.sub -a -- -b bval one two three
30
31 ${THIS_SH} ./getopts5.sub -a -c
32
33 ${THIS_SH} ./getopts6.sub -a
34 ${THIS_SH} ./getopts6.sub -a -c
35 ${THIS_SH} ./getopts6.sub -ac
36 echo $? # this should be 2
37
38 ${THIS_SH} ./getopts7.sub -a
39
40 ${THIS_SH} ./getopts8.sub
41 ${THIS_SH} ./getopts9.sub
42
43 ${THIS_SH} ./getopts10.sub