Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 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 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 12 | ${THIS_SH} ./getopts1.sub -a -b bval one two three |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 13 | # make sure getopts works when there are more than 9 positional parameters |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 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 |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 16 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 17 | ${THIS_SH} ./getopts2.sub -ad -c cval three four five |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 18 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 19 | ${THIS_SH} ./getopts3.sub |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 20 | |
| 21 | # make sure that `-b bval' and `-bbval' are equivalent |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 22 | ${THIS_SH} ./getopts4.sub -a -b bval one two three |
| 23 | ${THIS_SH} ./getopts4.sub -a -bbval one two three |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 24 | # this tests `silent' error reporting |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 25 | ${THIS_SH} ./getopts4.sub -a -b |
| 26 | ${THIS_SH} ./getopts4.sub -a -c |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 27 | |
| 28 | # make sure that `--' can be used to end the list of options |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 29 | ${THIS_SH} ./getopts4.sub -a -- -b bval one two three |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 30 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 31 | ${THIS_SH} ./getopts5.sub -a -c |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 32 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 33 | ${THIS_SH} ./getopts6.sub -a |
| 34 | ${THIS_SH} ./getopts6.sub -a -c |
| 35 | ${THIS_SH} ./getopts6.sub -ac |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 36 | echo $? # this should be 2 |
| 37 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 38 | ${THIS_SH} ./getopts7.sub -a |