procmail
[Top] [All Lists]

Re: How to do high-bit characters in procmail regexp ?

1999-12-10 12:58:51
On Thu, 9 Dec 1999, Silver wrote:
What is it that differentiates conditions and actions?  Is it simply that
actions are always the last line in a nest?

Conditions begin with `*'...
A scoring condition begin with  `* w^x ' where w and x are two real
numbers.

Could someone do this in Psuedocode for me?

:0HB
* -400
* -1^1 .
* 10^1 [X-Y]
| formail -A "X-Reject: High-bit character set in email"

If the mail (both body and header) matches the follow conditions (the
ending score is positive) pipe it to `formail -A "X-Reject: High-bit \
character set in email"' :
* First lower the score by 400 (-400^0)
* For each line lower the score with X where X is 1 first time and 1
   second time and so on (-1^1)
* For each line with one or more chars that's in the range of [X-Y]
   (`[a-z]' matches every char from `a' to `z') higher the score with X
   where X is 10 the first time and 10 the second time (and so on) (10^1)

For instance, definitians of 
:0 and the flags H and B (are these case sensitive?)

<man procmailrc>
  Recipes
     A line starting with ':' marks the beginning  of  a  recipe.
     It has the following format:

          :0 [flags] [ : [locallockfile] ]
          <zero or more conditions (one per line)>
          <exactly one action line>
</man procmailrc>

The `0' is from early in the procmail timeline... and if I understand
correctly it doesn't matter... Just use `0'...
The [flags] are indeed case sensitive...
`H' say that procmail should match the headers with the conditions and `B'
say that procmail should match the body with the conditions (and both
together say that procmail should condition both the header and the
body).

`h' say that procmail should use only the header in the actionline and `b'
say that procmail should use the only the body in the actionline...

* What does this mean?
-400  why the -, and why would Era say that a "^0" after the -400? 
Mathmatically, that is 1.  dunno.

Well... I think that the `-400' is a typo since that would match a line
with `-400' somewhere in it...
But `-400^0' matches the `w^e' that is scoring...
<man procmailsc>
Weighted regular expression conditions
     The first time the regular expression is found, it will  add
     w  to  the  score.  The second time it is found, w*x will be
     added.  The third time it is found,  w*x*x  will  be  added.
     The fourth time w*x*x*x will be added.  And so forth.
</man procmailsc>

So the `-400^0' will add -400 to the score the first time it is matched
and nothing the second time.

-1^1

This will add -1 to the score for every line that matches...

[X-Y]  Are these variables or flags?

Neither... It is a regular expression...
I think you will find the proper explaning in one of the manpages grep,
egrep, regex, regexp or some of the manpages refeered by those manpages.

And formail is a whole other subject I'll ask about later.  :)

`man formail' will explain some of those things...

-- 
Lots of girls can be had for a song.  
Unfortunately, it often turns out to be the wedding march.