Browse Source

Merge branch 'es/chain-lint-more'

The test linter code has learned that the end of here-doc mark
"EOF" can be quoted in a double-quote pair, not just in a
single-quote pair.

* es/chain-lint-more:
  chainlint: match "quoted" here-doc tags
maint
Junio C Hamano 6 years ago
parent
commit
e9983f8965
  1. 8
      t/chainlint.sed
  2. 2
      t/chainlint/here-doc.expect
  3. 7
      t/chainlint/here-doc.test
  4. 1
      t/chainlint/subshell-here-doc.expect
  5. 4
      t/chainlint/subshell-here-doc.test

8
t/chainlint.sed

@ -94,8 +94,8 @@ @@ -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/[ ]*<<//
:hered
N
@ -158,7 +158,7 @@ s/.*\n// @@ -158,7 +158,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
@ -280,7 +280,7 @@ bfolded @@ -280,7 +280,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/[ ]*<<//
:heredsub
N

2
t/chainlint/here-doc.expect

@ -4,4 +4,6 @@ cat >foo && @@ -4,4 +4,6 @@ cat >foo &&

cat >bar &&

cat >boo &&

horticulture

7
t/chainlint/here-doc.test

@ -21,6 +21,13 @@ boz @@ -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

1
t/chainlint/subshell-here-doc.expect

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

4
t/chainlint/subshell-here-doc.test

@ -31,5 +31,9 @@ @@ -31,5 +31,9 @@
glink
FIZZ
ARBITRARY2
cat <<-"ARBITRARY3" >bup3 &&
glink
FIZZ
ARBITRARY3
meep
)

Loading…
Cancel
Save