ash: import param_expand_default.tests from hush
[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 # bash doesn't accept ${#+}. ash prints 0 (not $#).
10 echo _${#+}_ _${#:+}_
11 # Forms with non-empty word work as expected in both ash and bash.
12 echo _${#+z}_ _${#:+z}_
13
14 # now some valid ones
15 set --
16 echo _$1 _${1+} _${1:+} _${1+word} _${1:+word}
17
18 set -- aaaa
19 echo _$1 _${1+} _${1:+} _${1+word} _${1:+word}
20
21 unset f
22 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
23
24 f=
25 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
26
27 f=fff
28 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}