Re: [PATCH v4 4/6] send-email: create email parser subroutine
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jun 8, 2016, 20:13 UTC
- Message-ID
- <CAPig+cQ5OKFTA8pEge=0e2RMT3ghmat-szw73aO_3WVW1=eAFQ@mail.gmail.com>
- In-Reply-To
- <fb7795c4-60db-94b3-a584-8fadd0440773@grenoble-inp.org>
On Wed, Jun 8, 2016 at 3:30 PM, Samuel GROOT <samuel.groot@grenoble-inp.org> wrote:
Show 13 quoted lines
> On 06/08/2016 08:12 PM, Eric Sunshine wrote: >> On Wed, Jun 8, 2016 at 1:58 PM, Junio C Hamano <gitster@pobox.com> wrote: >>> Samuel GROOT <samuel.groot@grenoble-inp.org> writes: >>> The pattern is not anchored at the right end of the string; >>> intended? Is it worth worrying about a lone '\r'? >> >> Thanks, I think you covered pretty much everything I was going to say. >> I'd just add that if the matching is going to be kept loose like this >> (rather than anchoring it), then s/[\r\n]+//g might be easier to read, >> but it's a minor point. > > Indeed s/[\r\n]+//g is way better, it works even if there's a CR in the > middle of the line.
An embedded CR probably shouldn't happen, but I'm not convinced that folding it out is a good idea. I would think that you'd want to preserve the header's value verbatim. If anything, I'd expect to see the regex tightened to:
s/\r?\n$//;
Alternately, consider using 'chop' or 'chomp'.