procmail
[Top] [All Lists]

Re: test variable value

2001-02-25 12:16:39
Dallman suggests that I forward this to the list in further answer to a
question posed recently. (I've not been keeping up lately with the list
for all the usual reasons.)

Rik

----- Forwarded message from Dallman Ross <dman(_at_)nomotek(_dot_)com> -----

From: Dallman Ross <dman(_at_)nomotek(_dot_)com>
To: rik(_at_)panix(_dot_)com
Cc: dman+noacks(_at_)nomotek(_dot_)com
Subject: procmail list
Date: Sat, 24 Feb 2001 09:02:51 -0500 (EST)
Message-Id: <200102241402(_dot_)JAA31813(_at_)ulysium(_dot_)ulysium(_dot_)net>
Sender: nomotek(_at_)ulysium(_dot_)ulysium(_dot_)net

From: Don Hammond <procmail1(_at_)tradersdata(_dot_)com>
Subject: Re: test variable value
To: procmail-users(_at_)procmail(_dot_)org

On 20 Feb, Philip Guenther wrote:
| "Timothy J. Luoma" <tjlists(_at_)bigfoot(_dot_)com> writes:
| >
| >how do I do the equivalent of
| >
| >   if [ "$VARIABLE" = "no"]; then
| >
| >in procmailrc?
| 
|     :0
|     * VARIABLE ?? ^^no^^
|     { whatever... }
| 

And my suggestion to Timothy was:

* VARIABLE ?? ^no$

No matter how many times I read a man page there's something new that
didn't register with me previously. I've changed a half dozen or so
of my recipes to Philip's method above, but am curious. His seems
clearly more appropriate to this usage, or rather ^ and $ seem more
suited to a  line-oriented search area. But is there a difference in
this case, or are they functionally equivalent here?  So far I'm
getting the same results from both and never noticed any problems
before, but maybe that was just dumb luck. Thanks.


Rik, I had thought you'd explained this to me last year.  I thought the
answer you wrote might be good here.  I looked, and finally found
it.  It was 1.5 years ago.  Perhaps you can just recycle this
and send to the list and the fellow above.

I'd do it, but I don't want to post private email without asking
first.

-----Original Message-----
From: Rik Kabel [mailto:rik]
Sent: Monday, 22 November 1999 10:28 PM
To: Dallman Ross
Subject: Re: working with variables


And what is that ^^ anchor stuff again?  I get confused when I
see it.

^^ anchors to the beginning or end of a variable, as distinguished
from ^ , which marks the beginning of a line. The body of a message
is a special variable, as is the head. Thus,
      :0
      * ^^From
matches the beginning From in a message (not From:, which is matched
by ^From) .

^^ is useful in ensuring that the scope of a condition is what you
want. For instance,
      :0
      * OBJECT ?? abc
is true if abc appears anywher in $OBJECT , while
      :0
      * OBJECT ?? ^^abc
requires OBJECT to start with abc , and
      :0
      * OBJECT ?? abc^^
requires abc to end $OBJECT , and
      :0
      * OBJECT ?? ^^abc^^
is true only when $OBJECT is abc and nothing else.


And:

-----Original Message-----
From: Rik Kabel [mailto:rik]
Sent: Tuesday, 23 November 1999 4:44 AM
To: Dallman Ross
Subject: Re: working with variables


You asked:
is a special variable, as is the head. Thus,
  :0
  * ^^From
matches the beginning From in a message (not From:, which is matched
by ^From) .

You mean as in

To: asdfad
From: asadf
Subject: asdasf

From me to you, this from at the start of this line?

No, I mean the From generated by sendmail (or equivalent) when it
delivers the message, as in the first line below:

From user datetimestamp
Return-Path: <user>
To: asdfad
From: asdf
Subject: asdasf

  :0
  * OBJECT ?? ^^abc^^
is true only when $OBJECT is abc and nothing else.

In sh this would be ^abc$   ?  Why not use one ^ at the
start?

Because  ^abc$  could match a line containing only  abc  in a
multiline value, whilst  ^^abc^^  is bound to the beginning and
end of the variable's value.

[snip]


-- 
Netcom has imploded.  Please now use NOTnetcom.com for mail.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Ex-Netcommies:  Mail "forwards" for free forwarding service!
NOT affiliated with EarthLink, Inc.'s Netcom brand identity.

----- End forwarded message -----

-- 
Rik Kabel      old enough to be an adult      rik(_at_)panix(_dot_)com
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail