Skip to content

Commit 2d53614

Browse files
sunshinecogitster
authored andcommitted
chainlint.sed: make here-doc "<<-" operator recognition more POSIX-like
According to POSIX, "<<" and "<<-" are distinct shell operators. For the latter to be recognized, no whitespace is allowed before the "-", though whitespace is allowed after the operator. However, the chainlint patterns which identify here-docs are both too loose and too tight, incorrectly allowing whitespace between "<<" and "-" but disallowing it between "-" and the here-doc tag. Fix the patterns to better match POSIX. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5be30d0 commit 2d53614

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/chainlint.sed

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888

8989
# here-doc -- swallow it to avoid false hits within its body (but keep the
9090
# command to which it was attached)
91-
/<<[ ]*[-\\'"]*[A-Za-z0-9_]/ {
92-
s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
91+
/<<-*[ ]*[\\'"]*[A-Za-z0-9_]/ {
92+
s/^\(.*\)<<-*[ ]*[\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
9393
s/[ ]*<<//
9494
:hered
9595
N
@@ -152,7 +152,7 @@ s/.*\n//
152152
}
153153
:folded
154154
# here-doc -- swallow it
155-
/<<[ ]*[-\\'"]*[A-Za-z0-9_]/bheredoc
155+
/<<-*[ ]*[\\'"]*[A-Za-z0-9_]/bheredoc
156156
# comment or empty line -- discard since final non-comment, non-empty line
157157
# before closing ")", "done", "elsif", "else", or "fi" will need to be
158158
# re-visited to drop "suspect" marking since final line of those constructs
@@ -274,7 +274,7 @@ bfolded
274274
# found here-doc -- swallow it to avoid false hits within its body (but keep
275275
# the command to which it was attached)
276276
:heredoc
277-
s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
277+
s/^\(.*\)<<-*[ ]*[\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</
278278
s/[ ]*<<//
279279
:hdocsub
280280
N

0 commit comments

Comments
 (0)