builtin-getopts () { run-file builtin-getopts "$@" } run-file () { local spec_name=$1; shift; sh-spec spec/$spec_name.test.sh --compare-shells --oils-bin-dir $PWD/bin "$@" } builtin-getopts: spec test case results

Results for builtin-getopts.test.sh

statusdashbashmkshashosh
pass 1822172021
ok 41430
BUG 21313
total2424242424
casedashbashmkshashoshdescription
0pass pass pass pass pass getopts empty
1pass pass pass pass pass getopts sees unknown arg
2pass pass pass pass pass getopts three invocations
3pass pass pass pass pass getopts resets OPTARG
4pass pass pass pass pass Basic getopts invocation
5pass ok ok pass pass getopts with invalid variable name
detailsdetails
6pass pass pass pass pass getopts with invalid flag
7pass pass pass pass pass getopts with with -
8pass pass pass pass pass getopts missing required argument
9pass pass pass pass pass getopts doesn't look for flags after args
10pass pass pass pass pass getopts with explicit args
11pass pass pass pass pass OPTIND
12pass pass BUG pass BUG OPTIND after multiple getopts with same spec
detailsdetails
13BUG pass BUG BUG BUG OPTIND after multiple getopts with different spec
detailsdetailsdetailsdetails
14pass BUG BUG pass BUG OPTIND narrowed down
detailsdetailsdetails
15pass pass pass pass pass Getopts parses the function's arguments
16pass pass pass pass pass Local OPTIND
17ok pass ok ok pass two flags: -ab
detailsdetailsdetails
18BUG pass pass pass pass flag and arg: -c10
details
19ok pass ok ok pass More Smooshing 1
detailsdetailsdetails
20ok pass ok ok pass More Smooshing 2
detailsdetailsdetails
21ok pass pass pass pass OPTIND should be >= 1 (regression)
details
22pass pass pass pass pass getopts bug #1523
23pass pass pass pass pass More regression for #1523
98 passed, 12 OK, 0 not implemented, 10 BUG, 0 failed, 0 timeouts, 0 cases skipped

Details on runs that didn't PASS

bash5 getopts with invalid variable name

stdout:
status=1 opt= OPTARG=foo OPTIND=3
stderr:
bash: line 2: getopts: `opt-': not a valid identifier
mksh5 getopts with invalid variable name

stdout:
status=1 opt= OPTARG= OPTIND=1
stderr:
mksh: <stdin>[2]: getopts: opt-: is not an identifier
mksh12 OPTIND after multiple getopts with same spec

stdout:
1
-
-
4
4
stderr:
mksh: <stdin>[15]: getopts: arguments changed since last call
osh12 OPTIND after multiple getopts with same spec

stdout:
1
-
-
4
4
stderr:
dash13 OPTIND after multiple getopts with different spec

stdout:
.
2
-
-
-
5
_
2
stderr:
No arg for -f option
mksh13 OPTIND after multiple getopts with different spec

stdout:
.
2
-
-
5
5
stderr:
mksh: <stdin>[16]: getopts: arguments changed since last call
ash13 OPTIND after multiple getopts with different spec

stdout:
.
2
-
-
-
5
_
2
stderr:
No arg for -f option
osh13 OPTIND after multiple getopts with different spec

stdout:
.
2
-
-
5
5
stderr:
bash14 OPTIND narrowed down

stdout:
a=1 b= c= d=1 e=E
stderr:
mksh14 OPTIND narrowed down

stdout:
a=1 b= c= d=1 e=E
stderr:
osh14 OPTIND narrowed down

stdout:
a=1 b= c= d=1 e=E
stderr:
dash17 two flags: -ab

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=2 opt=b OPTARG=
stderr:
mksh17 two flags: -ab

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=2 opt=b OPTARG=
stderr:
ash17 two flags: -ab

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=2 opt=b OPTARG=
stderr:
dash18 flag and arg: -c10

stdout:
OPTIND=2 opt=c OPTARG=10
OPTIND=2 opt=? OPTARG=10
stderr:
dash19 More Smooshing 1

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=3 opt=b OPTARG=hi
OPTIND=5 opt=c OPTARG=hello
stderr:
mksh19 More Smooshing 1

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=3 opt=b OPTARG=hi
OPTIND=5 opt=c OPTARG=hello
stderr:
ash19 More Smooshing 1

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=3 opt=b OPTARG=hi
OPTIND=5 opt=c OPTARG=hello
stderr:
dash20 More Smooshing 2

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=2 opt=b OPTARG=
OPTIND=2 opt=c OPTARG=10
stderr:
mksh20 More Smooshing 2

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=2 opt=b OPTARG=
OPTIND=2 opt=c OPTARG=10
stderr:
ash20 More Smooshing 2

stdout:
OPTIND=2 opt=a OPTARG=
OPTIND=2 opt=b OPTARG=
OPTIND=2 opt=c OPTARG=10
stderr:
dash21 OPTIND should be >= 1 (regression)

stdout:
stderr: 
dash: 1: Illegal number: -1