Skip to content

Commit 7e32a31

Browse files
sunshinecogitster
authored andcommitted
chainlint: match 'quoted' here-doc tags
A here-doc tag can be quoted ('EOF') or escaped (\EOF) to suppress interpolation within the body. Although, chainlint recognizes escaped tags, it does not know about quoted tags. For completeness, teach it to recognize quoted tags, as well. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2c29cc commit 7e32a31

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

t/chainlint.sed

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494

9595
# here-doc -- swallow it to avoid false hits within its body (but keep the
9696
# command to which it was attached)
97-
/<<[ ]*[-\\]*[A-Za-z0-9_]/ {
98-
s/^\(.*\)<<[ ]*[-\\]*\([A-Za-z0-9_][A-Za-z0-9_]*\)/<\2>\1<</
97+
/<<[ ]*[-\\']*[A-Za-z0-9_]/ {
98+
s/^\(.*\)<<[ ]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<</
9999
s/[ ]*<<//
100100
:hereslurp
101101
N
@@ -158,7 +158,7 @@ s/.*\n//
158158
/"[^'"]*'[^'"]*"/!bsqstring
159159
}
160160
# here-doc -- swallow it
161-
/<<[ ]*[-\\]*[A-Za-z0-9_]/bheredoc
161+
/<<[ ]*[-\\']*[A-Za-z0-9_]/bheredoc
162162
# comment or empty line -- discard since final non-comment, non-empty line
163163
# before closing ")", "done", "elsif", "else", or "fi" will need to be
164164
# re-visited to drop "suspect" marking since final line of those constructs
@@ -268,7 +268,7 @@ bcheckchain
268268
# found here-doc -- swallow it to avoid false hits within its body (but keep
269269
# the command to which it was attached)
270270
:heredoc
271-
s/^\(.*\)<<[ ]*[-\\]*\([A-Za-z0-9_][A-Za-z0-9_]*\)/<\2>\1<</
271+
s/^\(.*\)<<[ ]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<</
272272
s/[ ]*<<//
273273
:hereslurpsub
274274
N

t/chainlint/here-doc.expect

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ boodle wobba gorgo snoot wafta snurb &&
22

33
cat >foo &&
44

5+
cat >bar &&
6+
57
horticulture

t/chainlint/here-doc.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ boz
1414
woz
1515
Arbitrary_Tag_42
1616

17+
# LINT: swallow 'quoted' here-doc
18+
cat <<'FUMP' >bar &&
19+
snoz
20+
boz
21+
woz
22+
FUMP
23+
1724
# LINT: swallow here-doc (EOF is last line of test)
1825
horticulture <<\EOF
1926
gomez

t/chainlint/subshell-here-doc.expect

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
>) &&
66
(
77
cat >bup &&
8+
cat >bup2 &&
89
meep
910
>)

t/chainlint/subshell-here-doc.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@
2727
glink
2828
FIZZ
2929
ARBITRARY
30+
cat <<-'ARBITRARY2' >bup2 &&
31+
glink
32+
FIZZ
33+
ARBITRARY2
3034
meep
3135
)

0 commit comments

Comments
 (0)