procmail
[Top] [All Lists]

Re: Removing line-wrapped header

2004-09-10 06:22:52
On Fri, Sep 10, 2004 at 02:37:10PM +0200, Ruud H.G. van Tol wrote:

Toen wij Dallman Ross kietelden, kwam er dit uit:
Ruud:

one sed-call can do it.

Yup, I saved it before when you posted it.  Very nice!
Unfortunately, you did it too late in the day to spare me a couple
of hours of unplanned screwing around. :-) The exercise is still
useful if only as a tutorial (partly to myself).

One could also store the full headers in their original folded state
in a variable first, and work with that.


# is there a cheaper way to isolate the (non-unfolded) header-blob?
  :0w
  { my_HEADERS = `sed '/^$/q'` }

Slightly cheaper:

    :0 w
    { my_HEADERS = `formail -x ""` }

I'm not at all convinced we need the w flag or nested braces at
all.  I was of the belief that just

    my_HEADERS = `formail -x ""`

wouldn't tangle us in a race condition with whatever follows.



  NL    = "
" SPC   = " "
  TAB   = "     "
  b     = "[$SPC$TAB]"
  S     = "[^$SPC$TAB]"

  my_FIELD = "Received"
  my_REGEX = "by [a-z]+check"

  # Enjoy the way to get rid of the last line

I do!  I do!  :-)

The final $ isn't even needed, however, unless I'm misremembering from
yesterday's experiments.


  :0
  *$ my_HEADERS ?? ^^\/(.+$)+$\my_FIELD:.*(^$b.*)*$my_REGEX
  *$ MATCH ?? ^^\/.*(^.*)*^$S.*
  *  MATCH ?? ^^\/(.+$)+.
  *  MATCH ?? ^^\/(.*$)+..+$
  { my_HEAD = "$MATCH" }

  my_TAIL
  :0
  *$ my_HEADERS_??_^$\my_FIELD:.*(^$b.*)*.*$my_REGEX.*(^$b.*)*^\/$S.*(^.*)*^^
...........................................^^

I think the ".*" there is redundant.  I'm having trouble testing, because
the line is not matching in my test harness, and I don't have any more time
to try to see why not.  (Also, I added "_" in my quote of your condition,
twice, not because they should be there, but because this dumb mailing list
was wrapping the line, and I'm trying to avoid that so my ".....^^" will
line up right.)  I also think the "^^" at the end of your condition is
not required.

  { my_TAIL = "$MATCH" }

  :0 h fw
  | echo "$my_HEAD$my_TAIL$NL"


Nice going, Ruud.

Lather.  Rinse.  Repeat:  Nice going, Ruud.

We still need A flags (or bracing) on the second recipes to keep them
from invoking if the message is not one of our target ones.  Oh, and
we might as well put the test before the header-extraction backticks.

(I saw your emendation in the next mail, too.)

You too. And sed-user Gudermez rules.
http://groups.yahoo.com/group/sed-users/messages/4696
(if you have a yahoogroups-login)

Will check when I have time -- thanks.  I have a login, but never use it.

-- 
dman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>