chainlint: match 'quoted' here-doc tags
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 13 Aug 2018 08:47:35 +0000 (04:47 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Aug 2018 19:22:11 +0000 (12:22 -0700)
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>
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 2af1a687f839b729d1c44225adfb8ad8fb97938a..2901494e8ae32f01fd86b669ec6272d4a801da65 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
@@ -158,7 +158,7 @@ s/.*\n//
        /"[^'"]*'[^'"]*"/!bsqstring
 }
 # 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
@@ -268,7 +268,7 @@ bcheckchain
 # 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 33bc3cc0b4081f857ca61fea394b539831026589..aff65687168ec7e8e38cb4db79ada69b199da1ea 100644 (file)
@@ -2,4 +2,6 @@ boodle wobba        gorgo snoot        wafta snurb &&
 
 cat >foo &&
 
+cat >bar &&
+
 horticulture
index 8986eefe74ecf0624d85534970700159bf466ecd..f2bb14b693a4bf2a8c371bef82cb6d3aea453528 100644 (file)
@@ -14,6 +14,13 @@ boz
 woz
 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)
 horticulture <<\EOF
 gomez
index 7c2da63bc7c40d5b1eedf70d5e697dc5e892d1e2..7663ea7fc4adba607279a3f36c57200e9e56a800 100644 (file)
@@ -5,5 +5,6 @@
 >) &&
 (
        cat >bup &&
+       cat >bup2 &&
        meep
 >)
index 05139af0b5e1ad4414c53fbe70635e7878ef0be6..b6b5a9b33aac57156df37da5b3bc420baab78796 100644 (file)
@@ -27,5 +27,9 @@
        glink
        FIZZ
        ARBITRARY
+       cat <<-'ARBITRARY2' >bup2 &&
+       glink
+       FIZZ
+       ARBITRARY2
        meep
 )