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