chainlint: recognize multi-line $(...) when command cuddled with "$("
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 13 Aug 2018 08:47:36 +0000 (04:47 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Aug 2018 19:22:11 +0000 (12:22 -0700)
For multi-line $(...) expressions nested within subshells, chainlint.sed
only recognizes:

x=$(
echo foo &&
...

but it is not unlikely that test authors may also cuddle the command
with the opening "$(", so support that style, as well:

x=$(echo foo &&
...

The closing ")" is already correctly recognized when cuddled or not.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/chainlint.sed
t/chainlint/multi-line-nested-command-substitution.expect
t/chainlint/multi-line-nested-command-substitution.test
index 2901494e8ae32f01fd86b669ec6272d4a801da65..afb2443a9cfba05b05d08a9b9a0f4c30c2a21149 100644 (file)
@@ -216,7 +216,7 @@ s/.*\n//
 # "$(...)" -- command substitution; not closing ")"
 /\$([^)][^)]*)[^)]*$/bcheckchain
 # multi-line "$(...\n...)" -- command substitution; treat as nested subshell
-/\$([  ]*$/bnest
+/\$([^)]*$/bnest
 # "=(...)" -- Bash array assignment; not closing ")"
 /=(/bcheckchain
 # closing "...) &&"
index 19c023b1c871daa34df20735ca848a454bf647bc..59b6c8b850a16d087e5d322c8ee25dcbeb553fa5 100644 (file)
@@ -6,4 +6,13 @@
 >>     ) &&
        echo ok
 >) |
-sort
+sort &&
+(
+       bar &&
+       x=$(echo bar |
+               cat
+>>     ) &&
+       y=$(echo baz |
+>>             fip) &&
+       echo fail
+>)
index ca0620ab6b14b6bed39226565eb3d2d120f6f36e..300058341b6f303dce9d8e8105b6f16fa25f2ebf 100644 (file)
@@ -6,4 +6,13 @@
        ) &&
        echo ok
 ) |
-sort
+sort &&
+(
+       bar &&
+       x=$(echo bar |
+               cat
+       ) &&
+       y=$(echo baz |
+               fip) &&
+       echo fail
+)