procmail
[Top] [All Lists]

Re: Fixing up broken headers how?

2002-01-03 15:51:08
When my post finally got through, Gary responded,

| Not sure this does the intended job - because it preserves the original
header.

You're right.  Either I flubbed it when I wrote it, or I had something else
in mind and don't remember.  If you have a `b' flag on the recipe that
delivers it, the original head will be lost then.

| This seems to work, but single invocation of sed that you posted is a
| bit more efficient, and easier to understand.

OK.

|   :0 bfw  # fix up the body so it'll look like a mail message
|   | sed '/^From:/,$ \!d' | formail
|
|   :0 hfw  # ditch the original enclosing header
|   | cat > /dev/null

The way you are ditching the head runs both cat and a shell.  It's better
just to use a `b' flag on whatever later recipe delivers the message and let
the head get lost.  If you're concerned about forgetting to do that and you
absolutely do want to lose the head, then

(1) do it with fewer processes, such as

 :0hfi # no `w'; why would you want to recover?
 | true

(2) get rid of the head before you run the body through formail, because if
you run the body through formail first, the 'From ' line that formail will
put at the beginning of the body for you will get changed to '>From ';

(3) not having tested it yet, I'd feel a little safer filtering the entire
message at once through something that loses the head, because otherwise
procmail may do odd things when told to replace the head with nothing: maybe
that's not a concern and it would work properly, but just in case, as
before,

 :0fw
 * conditions
 | sed -e '1,/^$/d' -e '/^From:/,$ \!d' | formail

and just in case, as before, I'm sending this to
procmail(_at_)lists(_dot_)rwth-aachen(_dot_)de(_dot_)



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Fixing up broken headers how?, David W. Tamkin <=