procmail
[Top] [All Lists]

Re: [Q] Checking a score with $=

1998-07-11 15:02:46
Dave Larson asked,

| I have a script that uses weighted scoring.  For debugging purposes I am
| adding the score at the top of mail using formail. This all works fine if
| the mail meets the scoring requirement.
| 
| How can I check the score if my mail does not meet the scoring requirement?

I'm going to take Dave's question to mean, "How can I save the score if
the recipe that calculates it fails on grounds of a non-positive total
score?"

Easy enough: instead of this,

  :0fh maybe_other_flags
  * w^x condition1
  * w^x condition2
  * maybe_other_conditions
  | formail -A "X-Score-Was: $="

which filter the messsage only if the recipe passes (i.e., only if the score
is going to be greater than zero but not if the score is zero or negative),
do this:

  SCORE="not calculated" # in case something goes really wrong

  :0 flags
  * w^x condition1
  * w^x condition2
  * maybe_other_conditions
  { } # procmail's no-op

  SCORE = $=  # saved in variable even if zero or negative

  :0fh
  | formail -A "X-Score: $SCORE"

That way every message that gets to that point in the rcfile will be filtered.

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