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 <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Eric Sunshine 2018-08-13 04:47:35 -04:00 committed by Junio C Hamano
parent c2c29cc03e
commit 7e32a31b21
5 changed files with 18 additions and 4 deletions

View File

@ -94,8 +94,8 @@


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

View File

@ -2,4 +2,6 @@ boodle wobba gorgo snoot wafta snurb &&


cat >foo && cat >foo &&


cat >bar &&

horticulture horticulture

View File

@ -14,6 +14,13 @@ boz
woz woz
Arbitrary_Tag_42 Arbitrary_Tag_42


# LINT: swallow 'quoted' here-doc
cat <<'FUMP' >bar &&
snoz
boz
woz
FUMP

# LINT: swallow here-doc (EOF is last line of test) # LINT: swallow here-doc (EOF is last line of test)
horticulture <<\EOF horticulture <<\EOF
gomez gomez

View File

@ -5,5 +5,6 @@
>) && >) &&
( (
cat >bup && cat >bup &&
cat >bup2 &&
meep meep
>) >)

View File

@ -27,5 +27,9 @@
glink glink
FIZZ FIZZ
ARBITRARY ARBITRARY
cat <<-'ARBITRARY2' >bup2 &&
glink
FIZZ
ARBITRARY2
meep meep
) )