procmail
[Top] [All Lists]

Re: Re^3: copy subject content to body

1998-01-25 04:25:12
On Sun, 25 Jan 1998 18:53:42 +0900, Mitsuru Furukawa <furu(_at_)009(_dot_)com>
wrote:
Mitsuru Furukawa <furu(_at_)009(_dot_)com> wrote:
david hunt <dh(_at_)west(_dot_)net> wrote:
On Sun, 25 Jan 1998, Mitsuru Furukawa wrote:
:0f                        <=== Pls correct from here and after!
|  formail ;\
   echo "SUBJECT>$SSUBJECT"; \
   echo "<SUBJECT";
Adding an "h" flag to the above recipe would move the new lines to the top
of the message. You could substitute another program in place of formail,
such as cat, but I don't know a way to avoid a program altogether here, or
which would be more efficient.

The most efficient solution would probably be something like this:

    NL="
"
    :0fh
    | sed -e "\$a\\${NL}SUBJECT>${SUBJECT}\\${NL}<SUBJECT\\${NL}"

This gets a bit tricky because sed's syntax for embedding newlines in
scripts is not exactly straightforward, and Procmail is making this
harder still, and to top it off, the shell's quoting rules are getting
in the way, too. Unwrapped, in a normal shell script, this would look
something more or less like

sed -e '$a\
SUBJECT>'"$SUBJECT"'\
<SUBJECT\
'

This adds a newline after <SUBJECT as well for readability. Maybe you
don't really want that.

Note that this avoids spawning any shell at all (that's basically the
primary reason why this is better than formail plus echo). If you need
to run a sed script which contains one of the SHELLMETAS characters,
you might want to muck with SHELLMETAS temporarily to avoid spawning a
shell.

But on the other hand I am comfused
because body is still fed while "h" should mean "not to feed body".
Could you advise me on how should I interpret it?
Why original body is fed?

:hf means "filter only the header; leave the body untouched by the
filter program" so it is never seen by the script you use here. With
just :f you would be feeding both the headers and the body to the
script, but now, you feed it only the headers and Procmail replaces
the original headers with whatever the script produces. Luckily,
anything after the first blank line in the new headers will
subsequently be seen as part of the body of the message by Procmail.

Is it correct to assume that following recipe is "hidden"
or "automatically added" after the :0fh recipe?
         :0
         $DEFAULT

This (albeit with proper file locking, i.e. :0:) is implicit at the
end of the last .rc file Procmail processes. It is not clear from your
example if this is true in your case.

Hope this helps,

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

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