Skip to content

Commit 06fc5c9

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e32a31 commit 06fc5c9

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

t/chainlint.sed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ s/.*\n//
216216
# "$(...)" -- command substitution; not closing ")"
217217
/\$([^)][^)]*)[^)]*$/bcheckchain
218218
# multi-line "$(...\n...)" -- command substitution; treat as nested subshell
219-
/\$([ ]*$/bnest
219+
/\$([^)]*$/bnest
220220
# "=(...)" -- Bash array assignment; not closing ")"
221221
/=(/bcheckchain
222222
# closing "...) &&"

t/chainlint/multi-line-nested-command-substitution.expect

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@
66
>> ) &&
77
echo ok
88
>) |
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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@
66
) &&
77
echo ok
88
) |
9-
sort
9+
sort &&
10+
(
11+
bar &&
12+
x=$(echo bar |
13+
cat
14+
) &&
15+
y=$(echo baz |
16+
fip) &&
17+
echo fail
18+
)

0 commit comments

Comments
 (0)