chainlint: recognize multi-line $(...) when command cuddled with "$("

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>

Eric Sunshine committed Aug 13, 2018 at 04:47 UTC 06fc5c9f90da9be18371bafad5f35b6b17cbf49e
3 files changed +21 -3
t/chainlint.sed
+1 -1
@@ -216,7 +216,7 @@ s/.*\n//
216 # "$(...)" -- command substitution; not closing ")"
217 /\$([^)][^)]*)[^)]*$/bcheckchain
218 # multi-line "$(...\n...)" -- command substitution; treat as nested subshell
219 -/\$([ ]*$/bnest
219 +/\$([^)]*$/bnest
220 # "=(...)" -- Bash array assignment; not closing ")"
221 /=(/bcheckchain
222 # closing "...) &&"
t/chainlint/multi-line-nested-command-substitution.expect
+10 -1
@@ -6,4 +6,13 @@
6 >> ) &&
7 echo ok
8 >) |
9 -sort
9 +sort &&
10 +(
11 + bar &&
12 + x=$(echo bar |
13 + cat
14 +>> ) &&
15 + y=$(echo baz |
16 +>> fip) &&
17 + echo fail
18 +>)
t/chainlint/multi-line-nested-command-substitution.test
+10 -1
@@ -6,4 +6,13 @@
6 ) &&
7 echo ok
8 ) |
9 -sort
9 +sort &&
10 +(
11 + bar &&
12 + x=$(echo bar |
13 + cat
14 + ) &&
15 + y=$(echo baz |
16 + fip) &&
17 + echo fail
18 +)