procmail
[Top] [All Lists]

Re: Re^2: VARIABLE=result of sed?

1997-07-14 20:34:00
At 08:06 AM 7/15/97 +0900, Mitsuru Furukawa wrote:
era eriksson <era(_at_)iki(_dot_)fi> wrote:
[snip]
era> Correct alternative (1): just do an assignment.
era> 
era>   General form:
era>     VAR=value
era> 
era>     HEAD=`formail -X "" | sed -e 's/</\&lt;/g'`

This is same as my original. Could you re-state?

I think the confusion is about *where* you can use it and
have it "work"...

1)  By itself:
        HEAD=`formail -X "" | sed -e 's/</\&lt;/g'`
should work.

2)  In a recipe:
        :0
        * conditions <optional>
        HEAD=`formail -X "" | sed -e 's/</\&lt;/g'`
Now, as era noted, and you discovered, it's in an action line
specifying delivery to a folder whose name starts with "HEAD=".

3)  To set HEAD in a recipe:
        :0
        * conditions <optional>
        { HEAD=`formail -X "" | sed -e 's/</\&lt;/g'` }
should work, although you might as well use the "HEAD= |" form.
(The latter form might save a shell process; I'm not sure.)

(And as era noted, with your h flag you don't need formail at all,
but my cuts and pastes above don't deal with that.)


Note... the backticks and pipe really have nothing to do with the syntax
confusion... consider these much simpler examples analogous to the above;
if you relate these to the man pages, then the more complicated cases
should make sense:

1)  By itself:
        X=2
does what you expect.

2)  In a recipe action line:
        :0
        * conditions
        X=2
delivers to file "X=2"

3)  In a recipe:
        :0
        * conditions
        { X=2 }
probably does what you expect, setting the variable X to "2".

[snip]

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

Another point I don't know if Philip covers... the above examples, setting
HEAD, could produce amusing results if somewhere else the .procmailrc
assumes that $HEAD evaluates to /bin/head (or wherever it is)   :-)

Cheers,
Stan

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