]> git.ipfire.org Git - thirdparty/git.git/commitdiff
chainlint: match "quoted" here-doc tags
authorEric Sunshine <sunshine@sunshineco.com>
Wed, 29 Aug 2018 09:45:32 +0000 (05:45 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Aug 2018 17:57:38 +0000 (10:57 -0700)
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: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/chainlint.sed
t/chainlint/here-doc.expect
t/chainlint/here-doc.test
t/chainlint/subshell-here-doc.expect
t/chainlint/subshell-here-doc.test

index 8544df38dfc0c557120a8a250529147edbc3d2a4..1da58b554b1b287c0107a2b49f6061f137224eab 100644 (file)
@@ -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
@@ -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
@@ -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
index aff65687168ec7e8e38cb4db79ada69b199da1ea..534b065e38baa213da2a224e147cd41c649e55e8 100644 (file)
@@ -4,4 +4,6 @@ cat >foo &&
 
 cat >bar &&
 
+cat >boo &&
+
 horticulture
index f2bb14b693a4bf2a8c371bef82cb6d3aea453528..ad4ce8afd9b55650a2ce3751fbef3d67d07d534d 100644 (file)
@@ -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
index 7663ea7fc4adba607279a3f36c57200e9e56a800..74723e734043bd6300318b91a4874509c850460c 100644 (file)
@@ -6,5 +6,6 @@
 (
        cat >bup &&
        cat >bup2 &&
+       cat >bup3 &&
        meep
 >)
index b6b5a9b33aac57156df37da5b3bc420baab78796..f6b3ba4214a41de2ca9f9b91d2407e2f9dc4683c 100644 (file)
@@ -31,5 +31,9 @@
        glink
        FIZZ
        ARBITRARY2
+       cat <<-"ARBITRARY3" >bup3 &&
+       glink
+       FIZZ
+       ARBITRARY3
        meep
 )