procmail
[Top] [All Lists]

Re: Help with .procmailrc 2

1999-09-06 04:02:32
From: era eriksson <era(_at_)iki(_dot_)fi>

On Mon, 6 Sep 1999 09:40:12 +0200, "Mail Forward"
<diacom-all(_at_)diacom-systemhaus(_dot_)de> wrote:
 > all incomming mails should be forwarded to the username in
 > X-Envelope-To. only the username, for example: forward to "someone"
 > if x-env is <someone(_at_)somewhere(_dot_)com>
 > if this is not possible with a mail it must be forwarded to 
x(_at_)y(_dot_)z

A suitable recipe might be the following:

    :0
    * ^X-Envelope-To:[        <>]*\/[^        <>@]+
    ! "$MATCH"

    :0
    ! x(_at_)y(_dot_)z

The regular expression will match any non-whitespace non-broket non-@
characters after the initial whitespace/broket run. The whitespace
consists of one space and one tab, in both places.

If you're at all familiar with programming languages with regular
expression support such as sed, awk, or Perl, you should be able to
use that knowledge to construct valid and useful regular expressions
in Procmail, too. (grep is a good start, of course.)

I feel stuck in the 19th century (or rather, pre-3.10-and-earlier
algorithmic and regex thinking).  Basically, I feel that I can do a lot
of things with procmail, and know a fair amount about regex stuff.  But
ever since (about 2-3 years ago?) folks on this list started talking
extensively in terms like

    * ^X-Envelope-To:[        <>]*\/[^        <>@]+

I have felt lost. :-(  I will admit that I am only an occasional reader
of the posts to this list; although I have subscribed for a long
time, my life is often too hectic, and my procmail needs too static
or infrequent, to have kept up daily (or even weekly).  However, I
have skimmed things over the years when I've had time (and am always
glad to see old, familar "faces" here whose articles I know I can
read and whereby learn something worthwhile); and have read things
more reguarly during periods in which I've asked for help; but despite
my having tallied hours of reading via this lurking or "virtual
rubbernecking," I have not come to understand the above kind of syntax.

I fear that my skill with procmail, though certainly adequate
and perhaps even teetering toward "advanced," has stagnated because
of the wall that this new(ish) syntax style has erected.  Would
someone please be kind enough to explain, patiently and in
steps that an admitted middleweight procmailer can understand,
just how the above line works?  As in, ". . . and here we quote
a forward slash because it . . ."?  Wow, would that ever be
appreciated.  While I understand things like why a space and a tab
are inside brackets with a star afterward, and while I believe I
understand why the angle brackets are in there too, I get lost
(my eyes roll up into my brain and I can't think further) as soon
as I see the "\/" of a quoted slash and the one-to-ten ^ anchors
that you guys all have been interminably using for the last 3-4
years.  I just don't get that part!  I feel like I'm listening to
Binods (for those who remember the first season of (_ST:TNG_).

I should add that I'm advanced at sed, though "advanced" is,
admittedly, still one step removed from "expert."  But I do
understand lots about regexes.  Just not the procmailese
quoting and weird repetitive anchors that are bandied about
here like flowers strewn at a diva's feet.  :-)

As for me query of 36 hours ago that dattier replied to, I
appreciated it and will get back to that later today, hopefully.

-- 
    \     .-.     .-.     .-.     .-.     .-.     .-.     .-.     /
     \-d-/-m-\-a-/-n-\-(_at_)-/-n-\-e-/-t-\-c-/-o-\-m-/-.-\-c-/-o-\-m-/
      '-'     '-'     '-'     '-'     '-'     '-'     '-'     '-'