Thread (21 messages) flat view 21 messages, 6 authors, 2016-06-15

Re: [PATCH v2] Re: mailinfo: allow individual e-mail files as input

From: Brandon Casey <hidden>
Date: 2016-06-15 22:47:11

Nicolas Sebrecht wrote:
The 06/08/09, Brandon Casey wrote:
quoted
diff --git a/git-am.sh b/git-am.sh
index d64d997..49f2be4 100755
--- a/git-am.sh
+++ b/git-am.sh
<...>
quoted
+			{
+				echo "$l1"
+				echo "$l2"
+				echo "$l3"
+				cat
UUOC, I guess.
I needed to use google to figure out that UUOC means Useless Use Of Cat,
but I think you are mistaken.  Rather than trying to explain it, try this
with and without 'cat' commented out:

#!/bin/sh

{
    {
        echo "line one"
        echo "line two"
        cat
    } | sed -e 's/$/Q/'
} <<-EOF
This is a line of text
Here is another line of text.
And another
EOF

Hopefully you'll see the parallels to the sequence in git-am.sh and understand
that cat was used to send the rest of the email through sed along with the first
three lines that were read explicitly.  git-am.sh looks more like this:

   {
      read l1
      ...
      {
         echo "$l1"
         ...
         cat
      } | sed ...
   } << "$1"

At least, I thought that is how it looked until I read your other email where
you pointed out that "$1" is an argument to sed.
quoted
+			} | sed -n -e '/^$/q' -e '/^[ 	]/d' -e p "$1" |
                                                   ^^

Is it still needed?
Yes.  The '/^[ 	]/d' portion of the sed statement deletes any lines with
leading space or tab.  This avoids passing continuation fields to the
grep statement which is not designed for them, and so would fail (or
match, depending on how you look at it.  We used -v with grep).

-brandon
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help