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
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 $#): "len of $+"
11 # Forms with non-empty word work as expected in both ash and bash.
12 echo _${#+z}_ _${#:+z}_
16 echo _$1 _${1+} _${1:+} _${1+word} _${1:+word}
19 echo _$1 _${1+} _${1:+} _${1+word} _${1:+word}
22 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
25 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
28 echo _$f _${f+} _${f:+} _${f+word} _${f:+word}