procmail
[Top] [All Lists]

Re: Token syntax

1996-07-05 18:10:48
Stan Ryckman followed up,

| [stuff about my omitting caret deleted]
| 
| It was an error of mine not to use ^TO in my writing.  My apologies.
| Please make a global substitution of "^TO" for "TO" in what I wrote.

OK, thanks for explaining.

I had said,

| > ^TO.*DAY, however, is a bad idea,
| > because it eviscerates ^TO.  ^TODAY will not match "To: FARADAY", for
| > example, but ^TO.*DAY will, and you usually don't want it to.

And Stan clarified,

| No, I'd want ^TO.*DAY to match that, actually.

It will.  Frankly, I'd think of writing

  ^TO[a-z]*day

to match anything ending in day on a header line whose name is one of those
in the expansion of ^TO, but unless the character before "day" is a digit,
that ends up equivalent to ^TO.*day, so heck, ^TO.*day it is.  But most of
the time what follows ^TO is something you want to match only at the start
of a word.

| But how about ^TO.*tiac\.net for example?  Well, even that might be a
| stretch, but what the heck...

If you want to match destinations at pontiac.net and at any other site whose
name ends in tiac.net as well as those at tiac.net itself, then by all means 
use the .*.  If you want to match destinations at tiac.net, though, you do
not want the .*; better to use

   ^TOtiac\.net

or

   ^TO_([a-z]+\.)?tiac\.net

or to match destinations at tiac.net and pontiac.net but not at
aphroditiac.net (sorry, but I can't think of anything besides `Pontiac' that
really does end in "tiac" so I sank to misspelling `aphrodisiac'),

  ^TO(pon)?tiac\.net

| BTW:  The man page is even more confusing if you read it closely...
|      If the regular expression contains `^TO' it will be  substi-
|      tuted by `(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope
|      |Apparently(-Resent)?)-To):(.*[^a-zA-Z])?)', which should
|      catch all destination specifications.
| 
| This says that "xxx^TOyyy" is subject to such substitutions, but I
| don't think that's supposed to be the case.  Or is it?  I have a
| feeling that "starts with" rather than "contains" is the intent here.

I think it is.  Remember that the caret in the expansion of ^TO matches
the start of the search area or a newline.  Well, it won't match at the
start of the search area if xxx has to appear before it, but it can do
a multi-line match to these one after the other:

 xxx<newline>
 a line that starts with a match to ^TOyyy

| Or is it more complicated?  What does:
|       (xxx|^TOmyself)
| do?

It matches on either ^TOmyself or xxx, I'd suppose.

| But that ^TNX and ^TOX and ^TPX have grossly different syntactical
| or lexical (I'm not sure which) behavior is, IMHO, bizarre.  In two
| (and only two) of those cases, the X is not the start of a token; in
| the ^TOX case, it is.  I do not see a good reason for this being
| the case.  See what I mean?

Well, it grew up that way and we're stuck with it now.  I voiced a lot of
objection to Stephen when he used the same `c' flag for cloning procmail at
the start of a braced block that was already in use for making a simple
recipe non-delivering.  (The `c' was explained in the man pages as "continue"
and a lot of people -- including me the first time I tried braces out after
they had been introduced a couple versions earlier -- thought they needed a
`c' flag at the start of a braced block to make procmail continue into the
braces; up until then that had resulted in a harmless "extraneous c flag
ignored" error.  Now it would spawn a clone and have procmail operating both
inside and after the braces.)  I suggested that the new clone feature be
triggered with `C' instead.  But it was already in there, and when Roman
Czyborra suggested that we think of `c' as standing for "copy" rather than
"continue", that removed the risk of confusion.  Stephen updated the man
pages (though the source code still calls it "continue").

Put it on the list of quirks.

| > You can write your procmailrc code with a separator there,
| 
| Sorry if I might have implied I have a specific problem with getting
| something to work.  That is not the case at all.

You implied that you had a specific problem with getting procmailrc code to
look the way you felt it should.  You never said it didn't work.

| For those of you old enough, do you remember the "C" problem with:
|       x=-2;
| i.e., was it:
|       x =- 2;
| or:
|       x = -2;

I'm plenty old but have never studied C, so being old enough doesn't help.

| One more comment... it may seem really strange to you all that I'm
| even in this "debate" if I tell you that I have never had a use
| for ^TO or ^TO_ at all.  But it's true.

Nothing strange about it; this is a theoretical discussion.

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