procmail
[Top] [All Lists]

Re: strlen() in procmail

2003-01-14 22:13:38
On Tue, 14 Jan 2003, Professional Software Engineering wrote:

STRING is zero length, then the score is zero, and the action isn't 
taken.  Thus, for completeness:

#---
STRLEN=0

:0
* 1^1 STRING ?? > 1
{
         STRLEN=$=
}

LOG="The length of $STRING is $STRLEN$NL
#---

Hm.  Why not just:

--- snip ---
:0
* 1^1 STRING ?? > 1
{ }
STRLEN=$=
--- snip ---

While we're on the subject of short and complete ...

What's the most succinct way to set $MATCH without otherwise affecting
the outcome of the conditions?

That is, suppose I have a working recipe (fabricated example here):

:0c:
* ^Subject:\<+Re:
any_old_mailbox_will_do

Now, what I want next is $MATCH set to a string from some other header;
for example:

:0c:
* ^Subject:\<+Re:
* ^In-Reply-To:[^<]+<\/[^>]+
any_old_mailbox_will_do

Oops, I've changed the outcome!  The message now _must_ have an
In-Reply-To: header as well.  I didn't want that.

Yes, I could do it this way:

:0
* ^Subject:\<+Re:
{
 :0
 * ^In-Reply-To:[^<]+<\/[^>]+
 { }

 :0c:
 any_old_mailbox_will_do
}

But that's not very succinct -- I had to remember to move the c: inside
the braces, etc.  The best I can come up with is:

:0c:
* ^Subject:\<+Re:
* 1^0
* 1^0 ^In-Reply-To:[^<]+<\/[^>]+
any_old_mailbox_will_do

However, that changes $=, which is in a sense also changing the outcome.
I don't expect there's anything both short and free of (unwanted) side-
effects, but it can't hurt to involve a few additional brains.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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