procmail
[Top] [All Lists]

Re: regular expression language in procmail

1997-03-10 13:33:48
Mark McCreary wrote,

| So far so good.  However, I am still stumped on how truncate the -on
| portion of the address.  I cannot find any substring or truncation commands
| in procmail.

Well, at least not from the right.  Sometimes they can be faked, but taking
"-on" off the rightward end is tricky when the part you want to keep might
contain hyphens, o's, or n's.

| Or do I have access to shell commands ?  Does the $ command
| to evaluate conditions according to sh give me some leverage ?

Yes, you can use command substitution with backticks in a condition line that
has the $ modifier, but you don't need the $ modifier in an assignment:

   :0
   * MATCH ?? -on^^
   { savemetas=$SHELLMETAS # the asterisk below is not a globbing pattern
     baselist=`expr "$MATCH" : '\(.*\)-on'`
     SHELLMETAS=$savemetas }
   :0E
   { baselist=$MATCH }

I can't think of a good way to do it without an outside program.  There is
something in my mind, but it is not easily portable, and it requires one of
the more recent procmail versions that will let you reset MATCH in the middle
of a recipe for later conditions:

   grosslist=$MATCH
   :0
   * grosslist ?? -on^^
   * MATCH ?? ^^\/.*[^n]
   * MATCH ?? ^^\/.*[^o]
   * MATCH ?? ^^\/.*[^-]
   { baselist=$MATCH }
   :0E
   { baselist=$grosslist }

Unfortunately, a single condition like

  * MATCH ?? ^^\/.*[^-on]

will mess up if the last character before "-on" is an o or an n.

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