Skip to content
Snippets Groups Projects
Commit 3042b6bb authored by Eric Sunshine's avatar Eric Sunshine Committed by Junio C Hamano
Browse files

chainlint: match "quoted" here-doc tags


A here-doc tag can be quoted ('EOF'/"EOF") or escaped (\EOF) to suppress
interpolation within the body. chainlint recognizes single-quoted and
escaped tags, but does not know about double-quoted tags. For
completeness, teach it to recognize double-quoted tags, as well.

Signed-off-by: default avatarEric Sunshine <sunshine@sunshineco.com>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 4f69176f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -94,8 +94,8 @@
 
# here-doc -- swallow it to avoid false hits within its body (but keep the
# command to which it was attached)
/<<[ ]*[-\\']*[A-Za-z0-9_]/ {
s/^\(.*\)<<[ ]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<</
/<<[ ]*[-\\'"]*[A-Za-z0-9_]/ {
s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
s/[ ]*<<//
:hereslurp
N
Loading
Loading
@@ -159,7 +159,7 @@ s/.*\n//
}
:folded
# 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
# before closing ")", "done", "elsif", "else", or "fi" will need to be
# re-visited to drop "suspect" marking since final line of those constructs
Loading
Loading
@@ -281,7 +281,7 @@ bfolded
# found here-doc -- swallow it to avoid false hits within its body (but keep
# the command to which it was attached)
:heredoc
s/^\(.*\)<<[ ]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<</
s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
s/[ ]*<<//
:hereslurpsub
N
Loading
Loading
Loading
Loading
@@ -4,4 +4,6 @@ cat >foo &&
 
cat >bar &&
 
cat >boo &&
horticulture
Loading
Loading
@@ -21,6 +21,13 @@ boz
woz
FUMP
 
# LINT: swallow "quoted" here-doc
cat <<"zump" >boo &&
snoz
boz
woz
zump
# LINT: swallow here-doc (EOF is last line of test)
horticulture <<\EOF
gomez
Loading
Loading
Loading
Loading
@@ -6,5 +6,6 @@
(
cat >bup &&
cat >bup2 &&
cat >bup3 &&
meep
>)
Loading
Loading
@@ -31,5 +31,9 @@
glink
FIZZ
ARBITRARY2
cat <<-"ARBITRARY3" >bup3 &&
glink
FIZZ
ARBITRARY3
meep
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment