af1ee4fb363f28d2050e45678e5daa78ce9d3498
[platform/upstream/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} ./getopts.sub1 -a -b bval one two three
13 # make sure getopts works when there are more than 9 positional parameters
14 ${THIS_SH} ./getopts.sub1 -a -b bval one two three four five six seven eight nine ten eleven twelve
15 ${THIS_SH} ./getopts.sub1 -a -b 
16
17 ${THIS_SH} ./getopts.sub2 -ad -c cval three four five
18
19 ${THIS_SH} ./getopts.sub3
20
21 # make sure that `-b bval' and `-bbval' are equivalent
22 ${THIS_SH} ./getopts.sub4 -a -b bval one two three
23 ${THIS_SH} ./getopts.sub4 -a -bbval one two three
24 # this tests `silent' error reporting
25 ${THIS_SH} ./getopts.sub4 -a -b
26 ${THIS_SH} ./getopts.sub4 -a -c
27
28 # make sure that `--' can be used to end the list of options
29 ${THIS_SH} ./getopts.sub4 -a -- -b bval one two three
30
31 ${THIS_SH} ./getopts.sub5 -a -c
32
33 ${THIS_SH} ./getopts.sub6 -a
34 ${THIS_SH} ./getopts.sub6 -a -c
35 ${THIS_SH} ./getopts.sub6 -ac
36 echo $? # this should be 2
37
38 ${THIS_SH} ./getopts.sub7 -a