procmail
[Top] [All Lists]

Re: $= in action lines

1998-10-01 11:12:47
I suggested,

| >   :0fhw # B won't help; size conditions ignore H and B flags on the :0 line
| >   * ! ^Content-Length:.*[0-9]
| >   * 1^1 B ?? >1
| >   | formail -a "Content-Length:  $="
|                                    ^^^
| > [Yes, a space does work, at least when I tried it under procmail 3.11pre7
| >  and FreeBSD.]

Bill McClatchie asked,

| This works?  I know that the following hasn't worked for several people in
| the past:
| 
| | formail -I "X-score: $="

By "hasn't worked" do you mean that no X-Score: header was added, that the
wrong value was substituted for $=, or that $= was left as static text?

| In the past I've had to do something like this to get a score added to
| the headers:
| 
| VAL=$=
| 
| :0 fhw
| | formail -I "X-score: $VAL"

There are two reasons that wouldn't work:

1. The score is zero or negative, so the action line doesn't get run.
Besides the solution Bill posted, this should work also.

  :0 flags
  * conditions
  { }
  :0fwh
  | formail -I "X-Score: $="

2. Sometimes the action line isn't simply like that, and it also contains a
character from $SHELLMETAS.  (No, Dr. Daia, this is not properly documented
as far as I know.)  When procmail invokes a shell to handle a command, it
passes it along without variable substitution, just sending it as it sees it.
For variables with regular names, there is no difference because procmail
exports them; but for special variables like $_, $-, $=, and positional
parameters, the shell will have its own idea of what they represent.  For
example,

  :0:
  * weighted conditions
  | formail -I "X-Score: $=" >> some_folder

requires a shell, and the shell will decide how to interpret "$=".  It may
cause an error, be left as static text, or be replaced with something
unexpected.

Which was the problem in Bill's past experiences depends on what exactly
happened instead of getting the header added.

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