hush: fix ${##}, ${#?}, ${#!} handling
[oweals/busybox.git] / shell / hush_test / hush-vars / param_expand_assign.tests
1 # First try some invalid patterns. Do in subshell due to parsing error.
2 # (set argv0 to "SHELL" to avoid "/path/to/shell: blah" in error messages)
3 "$THIS_SH" -c 'echo ${=}' SHELL
4 "$THIS_SH" -c 'echo ${:=}' SHELL
5
6 # now some funky ones
7 "$THIS_SH" -c 'echo ${#=}' SHELL
8 "$THIS_SH" -c 'echo ${#:=}' SHELL
9
10 # should error out
11 "$THIS_SH" -c 'set --; echo _${1=}' SHELL
12 "$THIS_SH" -c 'set --; echo _${1:=}' SHELL
13 "$THIS_SH" -c 'set --; echo _${1=word}' SHELL
14 "$THIS_SH" -c 'set --; echo _${1:=word}' SHELL
15
16 # should not error
17 "$THIS_SH" -c 'set aa; echo _${1=}' SHELL
18 "$THIS_SH" -c 'set aa; echo _${1:=}' SHELL
19 "$THIS_SH" -c 'set aa; echo _${1=word}' SHELL
20 "$THIS_SH" -c 'set aa; echo _${1:=word}' SHELL
21
22 # should work fine
23 unset f; echo _$f
24 unset f; echo _${f=}
25 unset f; echo _${f:=}
26 unset f; echo _${f=word}
27 unset f; echo _${f:=word}
28
29 f=; echo _$f
30 f=; echo _${f=}
31 f=; echo _${f:=}
32 f=; echo _${f=word}
33 f=; echo _${f:=word}
34
35 f=fff; echo _$f
36 f=fff; echo _${f=}
37 f=fff; echo _${f:=}
38 f=fff; echo _${f=word}
39 f=fff; echo _${f:=word}