blob: 1814d7864b7cbcb08cd04d5a8bbe76bf91715e2b [file] [log] [blame]
Jari Aaltod166f041997-06-05 14:59:13 +00001# getopts tests
2# this should fail
3getopts
4echo $?
5getopts opts
6echo $?
7
8# maybe someday we will have a ksh93-like -a argument to set the name
9# used in error messages, but not yet
10getopts -a opts name
11
Jari Aaltocce855b1998-04-17 19:52:44 +000012${THIS_SH} ./getopts1.sub -a -b bval one two three
Jari Aaltod166f041997-06-05 14:59:13 +000013# make sure getopts works when there are more than 9 positional parameters
Jari Aaltocce855b1998-04-17 19:52:44 +000014${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 Aaltod166f041997-06-05 14:59:13 +000016
Jari Aaltocce855b1998-04-17 19:52:44 +000017${THIS_SH} ./getopts2.sub -ad -c cval three four five
Jari Aaltod166f041997-06-05 14:59:13 +000018
Jari Aaltocce855b1998-04-17 19:52:44 +000019${THIS_SH} ./getopts3.sub
Jari Aaltod166f041997-06-05 14:59:13 +000020
21# make sure that `-b bval' and `-bbval' are equivalent
Jari Aaltocce855b1998-04-17 19:52:44 +000022${THIS_SH} ./getopts4.sub -a -b bval one two three
23${THIS_SH} ./getopts4.sub -a -bbval one two three
Jari Aaltod166f041997-06-05 14:59:13 +000024# this tests `silent' error reporting
Jari Aaltocce855b1998-04-17 19:52:44 +000025${THIS_SH} ./getopts4.sub -a -b
26${THIS_SH} ./getopts4.sub -a -c
Jari Aaltod166f041997-06-05 14:59:13 +000027
28# make sure that `--' can be used to end the list of options
Jari Aaltocce855b1998-04-17 19:52:44 +000029${THIS_SH} ./getopts4.sub -a -- -b bval one two three
Jari Aaltod166f041997-06-05 14:59:13 +000030
Jari Aaltocce855b1998-04-17 19:52:44 +000031${THIS_SH} ./getopts5.sub -a -c
Jari Aaltod166f041997-06-05 14:59:13 +000032
Jari Aaltocce855b1998-04-17 19:52:44 +000033${THIS_SH} ./getopts6.sub -a
34${THIS_SH} ./getopts6.sub -a -c
35${THIS_SH} ./getopts6.sub -ac
Jari Aaltod166f041997-06-05 14:59:13 +000036echo $? # this should be 2
37
Jari Aaltocce855b1998-04-17 19:52:44 +000038${THIS_SH} ./getopts7.sub -a