Results for var-ref.test.sh

statusbashosh
pass 2428
ok 32
N-I 10
BUG 30
FAIL 01
total3131
casebashoshdescription
0pass pass var ref ${!a}
1pass pass ${!ref-default}
2ok pass ${!undef:-}
details
3BUG pass comparison to ${!array[@]} keys (similar SYNTAX)
details
4pass pass ${!a[@]-'default'} is legal but fails with more than one element
5pass pass var ref to $@ with @
6pass pass var ref to $1 and $2 with 1 and 2
7pass pass var ref: 1, @, *
8pass pass var ref to special var BASH_SOURCE
9pass pass var ref to $? with '?'
10pass pass Var ref, then assignment with ${ := }
11pass pass Var ref, then error with ${ ? }
12pass pass Indirect expansion, THEN suffix operators
13pass pass var ref OF array var -- silent a[0] decay
14pass pass array ref
15N-I pass array ref with strict_array
details
16pass pass var ref TO array var
17pass pass var ref TO array var, with subscripts
18pass pass var ref TO assoc array a[key]
19pass pass var ref TO array with arbitrary subscripts
20pass pass Bizarre tilde expansion in array index
21ok pass Indirect expansion TO fancy expansion features bash disallows
details
22pass ok Bad var ref
details
23pass ok Bad var ref 2
details
24pass pass ${!OPTIND} (used by bash completion
25ok pass var ref doesn't need cycle detection
details
26BUG pass Var Ref Code Injection $(tee PWNED)
details
27pass pass ${!array_ref:-set} and ${!array_ref:=assign}
28pass pass Array indirect expansion with suffix operators
29pass pass Array indirect expansion with replacements
30BUG FAIL Array indirect expansion with @? conversion
detailsdetails
52 passed, 5 OK, 1 not implemented, 3 BUG, 1 failed, 0 timeouts, 0 cases skipped
1 failed under osh

Details on runs that didn't PASS

bash2 ${!undef:-}

stdout:
NOUNSET
stderr:
bash: line 1: undef: invalid indirect expansion
bash: line 2: undef: invalid indirect expansion
bash: line 6: undef: invalid indirect expansion
bash: line 7: undef: invalid indirect expansion
bash3 comparison to ${!array[@]} keys (similar SYNTAX)

stdout:
['0', '1']
a_keys=0
['']
a_nobrackets=0
---
['A', 'B']
A_keys=0
['']
A_nobrackets=0
stderr:
bash15 array ref with strict_array

stdout:
ale
stderr:
bash: line 1: shopt: strict_array: invalid shell option name
bash21 Indirect expansion TO fancy expansion features bash disallows

stdout:
done
stderr:
main: line 2: a[0: invalid variable name
main: line 2: aa[k: invalid variable name
main: line 2: !x: invalid variable name
main: line 2: !a[0]: invalid variable name
main: line 2: x:-foo: invalid variable name
main: line 2: x:=foo: invalid variable name
main: line 2: x:?oops: invalid variable name
main: line 2: x:+yy: invalid variable name
main: line 2: x:0: invalid variable name
main: line 2: x:0:1: invalid variable name
main: line 2: !a@: invalid variable name
main: line 2: #x: invalid variable name
main: line 2: x#y: invalid variable name
main: line 2: x/y/foo: invalid variable name
main: line 2: x@Q: invalid variable name
osh22 Bad var ref

stdout:
stderr: 
  bad var name
     ^
[ contents of var 'a' at line 2 of [ stdin ] ]:1: Expected end of var ref expression
  echo ref ${!a}
              ^
[ stdin ]:2: fatal: Invalid var ref expression
osh23 Bad var ref 2

stdout:
stderr: 
  /
  ^
[ contents of var 'b' at line 2 of [ stdin ] ]:1: Expected var name
  echo ref ${!b}
              ^
[ stdin ]:2: fatal: Invalid var ref expression
bash25 var ref doesn't need cycle detection

stdout:
cycle=x
cycle=
stderr:
bash: line 7: warning: a: circular name reference
bash26 Var Ref Code Injection $(tee PWNED)

stdout:
42
PWNED
0
stderr:
bash30 Array indirect expansion with @? conversion

stdout:
==== v1 ====
["'value'"]
['value']
['']
==== v2 ====
["''"]
['']
['']
==== a1 ====
['']
['']
['a']
==== a2[0] ====
["'element'"]
['element']
['a']
==== a3[@] ====
["'1'", "'2'", "'3'"]
['1', '2', '3']
['a', 'a', 'a']
stderr:
osh30 Array indirect expansion with @? conversion

[osh stdout] Expected '==== v1 ====\n[\'value\']\n[\'value\']\n[\'\']\n==== v2 ====\n["\'\'"]\n[\'\']\n[\'\']\n==== a1 ====\n[\'\']\n[\'\']\n[\'a\']\n==== a2[0] ====\n[\'element\']\n[\'element\']\n[\'a\']\n==== a3[@] ====\n[\'1\', \'2\', \'3\']\n[\'1\', \'2\', \'3\']\n[\'a\', \'a\', \'a\']\n' Got '==== v1 ====\n[\'value\']\n[\'value\']\n[\'\']\n==== v2 ====\n["\'\'"]\n[\'\']\n[\'\']\n==== a1 ====\n[\'\']\n[\'\']\n[\'a\']\n==== a2[0] ====\n[\'element\']\n[\'element\']\n[\'\']\n==== a3[@] ====\n[\'1 2 3\']\n'
[osh status] Expected 0, got 1

stdout:
==== v1 ====
['value']
['value']
['']
==== v2 ====
["''"]
['']
['']
==== a1 ====
['']
['']
['a']
==== a2[0] ====
['element']
['element']
['']
==== a3[@] ====
['1 2 3']
stderr:
    argv.py "${!ref[@]@P}"
                      ^~
[ stdin ]:6: fatal: Can't use @P on BashArray