shell: remove ${#+} tests, it is not a valid construct
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 25 Jul 2017 22:30:02 +0000 (00:30 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 25 Jul 2017 22:30:02 +0000 (00:30 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash_test/ash-vars/param_expand_alt.right
shell/ash_test/ash-vars/param_expand_alt.tests
shell/hush_test/hush-vars/param_expand_alt.right
shell/hush_test/hush-vars/param_expand_alt.tests

index c733c147a5ad6544b37bec33e1fda49c6f6b3748..1303f80643494361611fccaf7f27db7efd81cfc8 100644 (file)
@@ -1,6 +1,6 @@
 SHELL: line 1: syntax error: bad substitution
 SHELL: line 1: syntax error: bad substitution
-_0_ __
+__
 _z_ _z_
 _ _ _ _ _
 _aaaa _ _ _word _word
index d80452434b8db7dfa76a32b53a25a91241ef956e..23e9a26be9c489290f0a8779a5ff472cfeed7058 100755 (executable)
@@ -6,8 +6,13 @@
 # now some funky ones.
 # ${V+word} "if V unset, then substitute nothing, else substitute word"
 # ${V:+word} "if V unset or '', then substitute nothing, else substitute word"
-# bash doesn't accept ${#+}. ash prints 0 (not $#): "len of $+"
-echo _${#+}_ _${#:+}_
+#
+# ${#:+} is a :+ op on $#, but ${#+} (and any other ${#c}) is "length of $c",
+# not + op on $#.
+# bash and dash do not accept ${#+}. it's possible for some shell to skip
+# the check that c is valid and interpret ${#+} as "len of $+". Not testing it.
+# echo _${#+}_
+echo _${#:+}_
 # Forms with non-empty word work as expected in both ash and bash.
 echo _${#+z}_ _${#:+z}_
 
index 4f9eb29071ced0c5c2179f6115d11b23fb7596d4..c46786e1fcc60cb7f6fdbc0163a4fde81e3143c0 100644 (file)
@@ -1,6 +1,6 @@
 hush: syntax error: unterminated ${name}
 hush: syntax error: unterminated ${name}
-__ __
+__
 _z_ _z_
 _ _ _ _ _
 _aaaa _ _ _word _word
index d80452434b8db7dfa76a32b53a25a91241ef956e..23e9a26be9c489290f0a8779a5ff472cfeed7058 100755 (executable)
@@ -6,8 +6,13 @@
 # now some funky ones.
 # ${V+word} "if V unset, then substitute nothing, else substitute word"
 # ${V:+word} "if V unset or '', then substitute nothing, else substitute word"
-# bash doesn't accept ${#+}. ash prints 0 (not $#): "len of $+"
-echo _${#+}_ _${#:+}_
+#
+# ${#:+} is a :+ op on $#, but ${#+} (and any other ${#c}) is "length of $c",
+# not + op on $#.
+# bash and dash do not accept ${#+}. it's possible for some shell to skip
+# the check that c is valid and interpret ${#+} as "len of $+". Not testing it.
+# echo _${#+}_
+echo _${#:+}_
 # Forms with non-empty word work as expected in both ash and bash.
 echo _${#+z}_ _${#:+z}_