Start 1.33.0 development cycle
[oweals/busybox.git] / shell / hush_test / hush-vars / param_expand_alt.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 ${+}  ; echo moo' SHELL
4 "$THIS_SH" -c 'echo ${:+} ; echo moo' SHELL
5
6 # now some funky ones.
7 # ${V+word} "if V unset, then substitute nothing, else substitute word"
8 # ${V:+word} "if V unset or '', then substitute nothing, else substitute word"
9 #
10 # ${#:+} is a :+ op on $#, but ${#+} (and any other ${#c}) is "length of $c",
11 # not + op on $#.
12 # bash and dash do not accept ${#+}. it's possible for some shell to skip
13 # the check that c is valid and interpret ${#+} as "len of $+". Not testing it.
14 # echo _${#+}_
15 echo _${#:+}_
16 # Forms with non-empty word work as expected in both ash and bash.
17 echo _${#+z}_ _${#:+z}_
18
19 # now some valid ones
20 set --
21 echo _$1 _${1+} _${1:+} _${1+word} _${1:+word}
22
23 set -- aaaa
24 echo _$1 _${1+} _${1:+} _${1+word} _${1:+word}
25
26 unset f
27 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
28
29 f=
30 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
31
32 f=fff
33 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}