]>
Commit | Line | Data |
---|---|---|
d166f048 JA |
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 | ||
cce855bc | 12 | ${THIS_SH} ./getopts1.sub -a -b bval one two three |
d166f048 | 13 | # make sure getopts works when there are more than 9 positional parameters |
cce855bc JA |
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 | |
d166f048 | 16 | |
cce855bc | 17 | ${THIS_SH} ./getopts2.sub -ad -c cval three four five |
d166f048 | 18 | |
cce855bc | 19 | ${THIS_SH} ./getopts3.sub |
d166f048 JA |
20 | |
21 | # make sure that `-b bval' and `-bbval' are equivalent | |
cce855bc JA |
22 | ${THIS_SH} ./getopts4.sub -a -b bval one two three |
23 | ${THIS_SH} ./getopts4.sub -a -bbval one two three | |
d166f048 | 24 | # this tests `silent' error reporting |
cce855bc JA |
25 | ${THIS_SH} ./getopts4.sub -a -b |
26 | ${THIS_SH} ./getopts4.sub -a -c | |
d166f048 JA |
27 | |
28 | # make sure that `--' can be used to end the list of options | |
cce855bc | 29 | ${THIS_SH} ./getopts4.sub -a -- -b bval one two three |
d166f048 | 30 | |
cce855bc | 31 | ${THIS_SH} ./getopts5.sub -a -c |
d166f048 | 32 | |
cce855bc JA |
33 | ${THIS_SH} ./getopts6.sub -a |
34 | ${THIS_SH} ./getopts6.sub -a -c | |
35 | ${THIS_SH} ./getopts6.sub -ac | |
d166f048 JA |
36 | echo $? # this should be 2 |
37 | ||
cce855bc | 38 | ${THIS_SH} ./getopts7.sub -a |