Re: [PATCH 1/5] chainlint: match arbitrary here-docs tags rather than hard-coded names
From: Jeff King <hidden>
Date: 2018-08-09 14:26:40
On Thu, Aug 09, 2018 at 01:58:05AM -0400, Eric Sunshine wrote:
On Wed, Aug 8, 2018 at 6:50 PM Jeff King [off-list ref] wrote:quoted
On Tue, Aug 07, 2018 at 04:21:31AM -0400, Eric Sunshine wrote:quoted
+# Swallowing here-docs with arbitrary tags requires a bit of finesse. When a +# line such as "cat <<EOF >out" is seen, the here-doc tag is moved to the front +# of the line enclosed in angle brackets as a sentinel, giving "<EOF>cat >out".Gross, but OK, as long as we would not get confused by a line that actually started with <EOF> at the start.It can't get confused by such a line. There here-doc swallower prepends that when it starts the swallowing process and removes it add the end. Even if a line actually started with that, it would become "<EOF><EOF>cmd" while swallowing the here-doc, and be restored to "<EOF>cmd" at the end. Stripping the "<EOF>" is done non-greedily, so it wouldn't remove both of them. Likewise, non-greedy matching is used for pulling the "EOF" out of the "<...>" when trying to match against the terminating "EOF" line, so there can be no confusion.
Thanks. I figured you probably had thought of that, but it seemed easier to ask than to wade through the sed code (I do feel like a bad person to give that answer, because IMHO one of the key things that makes open source work is a willingness to dig in yourself rather than asking; but I am making an exception for this sed code).
Yeah, I was going with the tighter uppercase-only which Jonathan suggested[1], but I guess it wouldn't hurt to re-roll to allow lowercase too. [...] No. I've gotten so used to \EOF in this codebase that it didn't occur to me to even think about 'EOF', but a re-roll could add that, as well.
Thanks. I could take or leave such fixes, since I think our style discourages both, so I'll leave it up to you whether you want to pursue them. -Peff