procmail
[Top] [All Lists]

Re: existence of a field?

1997-05-21 14:04:00
Luke Davis wrote,

| The construct:
| 
| listname | formail -rxx-list-id:
| 
| Will put the contents of the x-list-id: field into the var "listname".
| (well, it does that in v3.10, anyway).

No, it doesn't.

First, the variable capture syntax requires an equal sign as well as a pipe:

  :0 flags
  * conditions if any
  variable=|command

So what Luke needs is more like this:

  :0
  * ^X-List-Id:
  listname=| formail -rxx-list-id:

Second, formail's -r option does not preserve an X-List-Id: field the
way it would preserve X-Loop:.  There's really no need to invert the
header for responding in this situation, so the easiest way is to drop
the -r:

  :0
  * ^X-List-Id:
  listname=| formail -xx-list-id:

I'd also imagine that any leading space in the contents of the X-List-Id:
field is of no value here, so we should use formail's -z option to get rid of
it:

  :0
  * ^X-List-Id:
  listname=| formail -zxx-list-id:

Still, if all we're doing is extracting text, it's more efficient to do
that within procmail rather than by calling another program (such as
formail) for it:

  :0
  * ^X-List-Id: *\/[^ ].*
  { listname=$MATCH }

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