procmail
[Top] [All Lists]

Removing new lines in MATCH

2000-03-30 22:14:21
I have a procmail file which looks for a particular sting which could be
broken accross lines.. No problme it finds the string ok.

When a match is found I want it put into a mail header before it is
delivered to a folder so I can see what was matched...


Example...

TAB  = "        "   # a single tab
SPC  = "[ $TAB]"
SPCL = ""($SPC|$)"

# Later...

JUNK = _Junk    # a Mh folder (rcvstore used for deliver for correct
                #              unseen-cache handling)
OR=9876543210   # Ultra large score for OR'ed conditions -- Jari's Tips #8.18

X="$SPCL+"      # word seperator

:0 Bfh
* $ $OR^0 ()\/this${X}is${X}just${X}a${X}test${X}match
* $ $OR^0 ()\/kill${X}me${X}please
* $ $OR^0 ()\/I${X}am${X}only${X}kidding
| formail -i "X-Junk-Match: $MATCH" 
:0 A
| rcvstore +$JUNK

The works but...

Problems...

  1/ The header line will only contain the matched string up
     until the first new line.
  2/ Also Formail seems to lowercase all but the first letter (the X)
     I can live with this but it is annoying.

So I used the shell to remove the extra spaces which should be safe from
attach as only matches strings could be open for shell parsing.
As a shell is being called anyway I can also combine the two commands

* .. as above
| formail -i "X-Junk-Match: `echo $MATCH`" | rcvstore +$JUNK

This is horible and probably not good for all posibilities.


Does any one have a better way of fixing the newline in MATCH ?

ASIDE: What procmail is badly in need of is a regular expresion
substution function, maybe a minimalistic sed `s' function, I mean I
understands RE's so it should not be too much extra and probably would
resolve a lot of existing procmail `wierd coding' practices.

  Anthony Thyssen ( System Programmer )    http://www.sct.gu.edu.au/~anthony/
- --------------------------------------------------------------------------- -
  You are caught in a maze of twisty little Sendmail rules, all obscure.
- --------------------------------------------------------------------------- -
     PGP Public Key available -- finger -l 
anthony(_at_)lyrch(_dot_)cit(_dot_)gu(_dot_)edu(_dot_)au  

<Prev in Thread] Current Thread [Next in Thread>
  • Removing new lines in MATCH, Anthony Thyssen <=