procmail
[Top] [All Lists]

Re: VARIABLE=result of sed?

1997-07-14 02:44:00
On Mon, 14 Jul 1997 08:47:33 +0900, Mitsuru Furukawa <furu(_at_)009(_dot_)com>
wrote:
I want to extract header part and sed it and put into $HEAD.
So I wrote:
  :0hc
   HEAD=`$FORMAIL -X "" |sed -e 's/</\&lt;/g'`
The log shows sed is working as expected, but $HEAD is empty.

This is not doing what you expect. This is a mixture of two different
ways to do things. (I'd expect you'll find a strangely named folder
whose name starts with "HEAD=" somewhere in your mail directory ;^)
  A procmailrc file, seen on a high level of abstraction, consists of
assignments and recipes. Here, you have mixed assignment syntax into a
recipe. Not good. 

Correct alternative (1): just do an assignment.

  General form:
    VAR=value

    HEAD=`formail -X "" | sed -e 's/</\&lt;/g'`

Correct alternative (2): a recipe with a slightly peculiar action
line. 

  General form:
    :0flags...
    [ * conditions ... ]
    [ VAR= ] | action

    :0hw
    HEAD= | formail -X "" | sed -e 's/</\&lt;/g'

By the way, the call to formail is unnecessary here, because you are
already feeding in only the headers (by way of the :h flag). Thus,
this should be a more efficient solution:

    :0hw
    HEAD= | sed -e 's/</\&lt;/g'

Philip's standard gripe about setting your PATH correctly instead of
defining a variable FORMAIL can be found in the archives ... :-)

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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