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: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4f69176feb
commit
3042b6bb59
@ -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
|
||||||
@ -159,7 +159,7 @@ s/.*\n//
|
|||||||
}
|
}
|
||||||
:folded
|
:folded
|
||||||
# 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
|
||||||
@ -281,7 +281,7 @@ bfolded
|
|||||||
# 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
|
||||||
|
@ -4,4 +4,6 @@ cat >foo &&
|
|||||||
|
|
||||||
cat >bar &&
|
cat >bar &&
|
||||||
|
|
||||||
|
cat >boo &&
|
||||||
|
|
||||||
horticulture
|
horticulture
|
||||||
|
@ -21,6 +21,13 @@ boz
|
|||||||
woz
|
woz
|
||||||
FUMP
|
FUMP
|
||||||
|
|
||||||
|
# LINT: swallow "quoted" here-doc
|
||||||
|
cat <<"zump" >boo &&
|
||||||
|
snoz
|
||||||
|
boz
|
||||||
|
woz
|
||||||
|
zump
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
(
|
(
|
||||||
cat >bup &&
|
cat >bup &&
|
||||||
cat >bup2 &&
|
cat >bup2 &&
|
||||||
|
cat >bup3 &&
|
||||||
meep
|
meep
|
||||||
>)
|
>)
|
||||||
|
@ -31,5 +31,9 @@
|
|||||||
glink
|
glink
|
||||||
FIZZ
|
FIZZ
|
||||||
ARBITRARY2
|
ARBITRARY2
|
||||||
|
cat <<-"ARBITRARY3" >bup3 &&
|
||||||
|
glink
|
||||||
|
FIZZ
|
||||||
|
ARBITRARY3
|
||||||
meep
|
meep
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user