procmail
[Top] [All Lists]

Re: RECIP vs $RECIP

2006-07-10 09:35:39
Bart Schaefer wrote:

On 7/10/06, $Bill Luebkert <dbecoll(_at_)adelphia(_dot_)net> wrote:

I got to experimenting with the $RECIP thingy and I'm at a loss.
$RECIP seems to work and RECIP seems to fail for me


You're not using the same test that the ISP is using.

The parse of

* $RECIP ?? pattern

is approximately

*           Begin a condition
$           The pattern part of this condition will contain variable 
expansions
RECIP   Token -- might be part of the pattern, might be a variable name
??         Preceding token is a variable name, rest of line is the pattern

Note in particular that $ is not part of a token "$RECIP", it's an
introducer like "!" (for a negated test) or "?" (for a test against an
external process result).  When you used it in

* $RECIP ?? ^^perl(_at_)$DOMAIN

you need it, because you have a reference to $DOMAIN in the pattern
(and I presume you are not trying to match "perl@" end-of-line
"DOMAIN").  The ISP did not have any such reference in the pattern
part, and therefore didn't need it.  The fact that both you and the
ISP wrote this as

* $RECIP ?? ...

(no space after the $) rather than the clearer

* $ RECIP ?? ...

merely points out that neither of you really understands what you
wrote, 

Of course not - I'm just a beginner.  :)

       which worries me in the case of an ISP.  They might later
insert a $ into the pattern expecting it to mean end-of-line, and
instead it would be taken as part of a variable reference.

OK - the lightbulb is starting to go on.  So essentially, these are
equivalent:

        * $RECIP ?? ^^perl(_at_)$DOMAIN
        * $ RECIP ?? ^^perl(_at_)$DOMAIN
but the latter is definitely preferred as being clearer.

And this (although not perfect) will still work (as long as no pattern 
interpolation/$)
        * $ RECIP ?? ^\/[^(_at_)]+
but should look like this to be more accurate and to prevent future screwups
        * RECIP ?? ^\/[^(_at_)]+

Right ?   I made the changes and it seems ok.

Thanks procmail man. :)


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail