[3320] | 1 | # do all of these in subshells since it's supposed to error out
|
---|
| 2 |
|
---|
| 3 | # first try some invalid patterns
|
---|
| 4 | #"$THIS_SH" -c 'echo ${?}' -- this is valid as it's the same as $?
|
---|
| 5 | "$THIS_SH" -c 'echo ${:?}'
|
---|
| 6 |
|
---|
| 7 | # then some funky ones
|
---|
| 8 | # note: bash prints 1 - treats it as "length of $#"? We print 0
|
---|
| 9 | "$THIS_SH" -c 'echo ${#?}'
|
---|
| 10 | # bash prints 0
|
---|
| 11 | "$THIS_SH" -c 'echo ${#:?}'
|
---|
| 12 |
|
---|
| 13 | # now some valid ones
|
---|
| 14 | export msg_unset="unset!"
|
---|
| 15 | export msg_null_or_unset="null or unset!"
|
---|
| 16 |
|
---|
| 17 | echo ====
|
---|
| 18 | "$THIS_SH" -c 'set --; echo _$1'
|
---|
| 19 | "$THIS_SH" -c 'set --; echo _${1?}'
|
---|
| 20 | "$THIS_SH" -c 'set --; echo _${1:?}'
|
---|
| 21 | "$THIS_SH" -c 'set --; echo _${1?message1}'
|
---|
| 22 | "$THIS_SH" -c 'set --; echo _${1:?message1}'
|
---|
| 23 | "$THIS_SH" -c 'set --; echo _${1?$msg_unset}'
|
---|
| 24 | "$THIS_SH" -c 'set --; echo _${1:?$msg_null_or_unset}'
|
---|
| 25 |
|
---|
| 26 | echo ====
|
---|
| 27 | "$THIS_SH" -c 'set -- aaaa; echo _$1'
|
---|
| 28 | "$THIS_SH" -c 'set -- aaaa; echo _${1?}'
|
---|
| 29 | "$THIS_SH" -c 'set -- aaaa; echo _${1:?}'
|
---|
| 30 | "$THIS_SH" -c 'set -- aaaa; echo _${1?word}'
|
---|
| 31 | "$THIS_SH" -c 'set -- aaaa; echo _${1:?word}'
|
---|
| 32 | "$THIS_SH" -c 'set -- aaaa; echo _${1?$msg_unset}'
|
---|
| 33 | "$THIS_SH" -c 'set -- aaaa; echo _${1:?$msg_null_or_unset}'
|
---|
| 34 |
|
---|
| 35 | echo ====
|
---|
| 36 | "$THIS_SH" -c 'unset f; echo _$f'
|
---|
| 37 | "$THIS_SH" -c 'unset f; echo _${f?}'
|
---|
| 38 | "$THIS_SH" -c 'unset f; echo _${f:?}'
|
---|
| 39 | "$THIS_SH" -c 'unset f; echo _${f?message3}'
|
---|
| 40 | "$THIS_SH" -c 'unset f; echo _${f:?message3}'
|
---|
| 41 | "$THIS_SH" -c 'unset f; echo _${f?$msg_unset}'
|
---|
| 42 | "$THIS_SH" -c 'unset f; echo _${f:?$msg_null_or_unset}'
|
---|
| 43 |
|
---|
| 44 | echo ====
|
---|
| 45 | "$THIS_SH" -c 'f=; echo _$f'
|
---|
| 46 | "$THIS_SH" -c 'f=; echo _${f?}'
|
---|
| 47 | "$THIS_SH" -c 'f=; echo _${f:?}'
|
---|
| 48 | "$THIS_SH" -c 'f=; echo _${f?word}'
|
---|
| 49 | "$THIS_SH" -c 'f=; echo _${f:?message4}'
|
---|
| 50 | "$THIS_SH" -c 'f=; echo _${f?$msg_unset}'
|
---|
| 51 | "$THIS_SH" -c 'f=; echo _${f:?$msg_null_or_unset}'
|
---|
| 52 |
|
---|
| 53 | echo ====
|
---|
| 54 | "$THIS_SH" -c 'f=fff; echo _$f'
|
---|
| 55 | "$THIS_SH" -c 'f=fff; echo _${f?}'
|
---|
| 56 | "$THIS_SH" -c 'f=fff; echo _${f:?}'
|
---|
| 57 | "$THIS_SH" -c 'f=fff; echo _${f?word}'
|
---|
| 58 | "$THIS_SH" -c 'f=fff; echo _${f:?word}'
|
---|
| 59 | "$THIS_SH" -c 'f=fff; echo _${f?$msg_unset}'
|
---|
| 60 | "$THIS_SH" -c 'f=fff; echo _${f:?$msg_null_or_unset}'
|
---|