]>
Commit | Line | Data |
---|---|---|
8868edaf CR |
1 | # This program is free software: you can redistribute it and/or modify |
2 | # it under the terms of the GNU General Public License as published by | |
3 | # the Free Software Foundation, either version 3 of the License, or | |
4 | # (at your option) any later version. | |
5 | # | |
6 | # This program is distributed in the hope that it will be useful, | |
7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9 | # GNU General Public License for more details. | |
10 | # | |
11 | # You should have received a copy of the GNU General Public License | |
12 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
13 | # | |
d166f048 JA |
14 | # getopts tests |
15 | # this should fail | |
16 | getopts | |
17 | echo $? | |
18 | getopts opts | |
19 | echo $? | |
20 | ||
21 | # maybe someday we will have a ksh93-like -a argument to set the name | |
22 | # used in error messages, but not yet | |
23 | getopts -a opts name | |
24 | ||
cce855bc | 25 | ${THIS_SH} ./getopts1.sub -a -b bval one two three |
d166f048 | 26 | # make sure getopts works when there are more than 9 positional parameters |
cce855bc JA |
27 | ${THIS_SH} ./getopts1.sub -a -b bval one two three four five six seven eight nine ten eleven twelve |
28 | ${THIS_SH} ./getopts1.sub -a -b | |
d166f048 | 29 | |
cce855bc | 30 | ${THIS_SH} ./getopts2.sub -ad -c cval three four five |
d166f048 | 31 | |
cce855bc | 32 | ${THIS_SH} ./getopts3.sub |
d166f048 JA |
33 | |
34 | # make sure that `-b bval' and `-bbval' are equivalent | |
cce855bc JA |
35 | ${THIS_SH} ./getopts4.sub -a -b bval one two three |
36 | ${THIS_SH} ./getopts4.sub -a -bbval one two three | |
d166f048 | 37 | # this tests `silent' error reporting |
cce855bc JA |
38 | ${THIS_SH} ./getopts4.sub -a -b |
39 | ${THIS_SH} ./getopts4.sub -a -c | |
d166f048 JA |
40 | |
41 | # make sure that `--' can be used to end the list of options | |
cce855bc | 42 | ${THIS_SH} ./getopts4.sub -a -- -b bval one two three |
d166f048 | 43 | |
cce855bc | 44 | ${THIS_SH} ./getopts5.sub -a -c |
d166f048 | 45 | |
cce855bc JA |
46 | ${THIS_SH} ./getopts6.sub -a |
47 | ${THIS_SH} ./getopts6.sub -a -c | |
48 | ${THIS_SH} ./getopts6.sub -ac | |
d166f048 JA |
49 | echo $? # this should be 2 |
50 | ||
cce855bc | 51 | ${THIS_SH} ./getopts7.sub -a |
a0c0a00f CR |
52 | |
53 | ${THIS_SH} ./getopts8.sub | |
54 | ${THIS_SH} ./getopts9.sub | |
55 | ||
56 | ${THIS_SH} ./getopts10.sub |