1 ## compare_shells: dash bash mksh
2
3 # Corner cases in var sub. Maybe rename this file.
4
5 #### Bad var sub
6 echo ${a&}
7 ## stdout-json: ""
8 ## status: 2
9 ## OK bash/mksh status: 1
10
11 #### Braced block inside ${}
12 # NOTE: This bug was in bash 4.3 but fixed in bash 4.4.
13 echo ${foo:-$({ ls /bin/ls; })}
14 ## stdout: /bin/ls
15
16 #### Nested ${}
17 bar=ZZ
18 echo ${foo:-${bar}}
19 ## stdout: ZZ
20
21 #### Filename redirect with "$@"
22 # bash - ambiguous redirect -- yeah I want this error
23 # - But I want it at PARSE time? So is there a special DollarAtPart?
24 # MultipleArgsPart?
25 # mksh - tries to create '_tmp/var-sub1 _tmp/var-sub2'
26 # dash - tries to create '_tmp/var-sub1 _tmp/var-sub2'
27 fun() {
28 echo hi > "$@"
29 }
30 fun _tmp/var-sub1 _tmp/var-sub2
31 ## status: 1
32 ## OK dash status: 2
33
34 #### Descriptor redirect to bad "$@"
35 # All of them give errors:
36 # dash - bad fd number, parse error?
37 # bash - ambiguous redirect
38 # mksh - illegal file descriptor name
39 set -- '2 3' 'c d'
40 echo hi 1>& "$@"
41 ## status: 1
42 ## OK dash status: 2
43
44 #### Here doc with bad "$@" delimiter
45 # bash - syntax error
46 # dash - syntax error: end of file unexpected
47 # mksh - runtime error: here document unclosed
48 #
49 # What I want is syntax error: bad delimiter!
50 #
51 # This means that "$@" should be part of the parse tree then? Anything that
52 # involves more than one token.
53 fun() {
54 cat << "$@"
55 hi
56 1 2
57 }
58 fun 1 2
59 ## status: 2
60 ## stdout-json: ""
61 ## OK mksh status: 1