procmail
[Top] [All Lists]

Re: stripping MATCH's right hand side

2001-12-07 13:43:42
Paul responded to Martin,

| Is it possible to use a backquote expansion as part of the action
| itself?

That depends, but in this use -- figuring out part of the name of a folder --
the answer is yes, as Martin has said.

| What about something like:
| 
|       :0
|       * 
^List-Unsubscribe:.*leave-isp-\/(_dot_)*(_at_)(_dot_)*isp-lists(_dot_)com
|       isp-`echo "$MATCH" | sed -E 's/-[^-]+(_at_)(_dot_)*$//'`
| 
| to avoid bothering with the variable assignment?  Is there any risk
| involved with leaving out the process of definine a variable?

That's fine, no problem, but since I like ksh (well, pdksh) for $SHELL I'd
rather use just the shell than a shell plus sed:

 :0
 * ^List-Unsubscribe:.*leave-isp-\/(_dot_)*(_at_)(_dot_)*isp-lists(_dot_)com
 isp-`ksh -c 'echo ${MATCH%%-*}'`

| (And yes, David, I know that sed -E doesn't work in all operating systems.)

It's not the operating systems: it's the sed sources.  But that's not a
problem:

 echo "$MATCH" | sed 's/-[^-]*(_at_)(_dot_)*$//'

Martin ansered,

: Certainly.  That should work fine (ignoring the fact that I have no idea
: what '-E' does to sed :-)).

It activates extended regular expressions, something like those known to
egrep but not to grep.

Paul answered me,

| Well, if you're going to go that route, you could as easily make it:

|       :0:
|       * ^List-.*\.isp-lists\.com>$
|       * ^List-Unsubscribe:.*:leave-\/isp-[a-z]+
|       $MATCH

| in order to avoid having to include specific lists in your procmail
| rules, but that doesn't cover the possibility that a list name will
| include a non-alpha character.

Bingo.  That's why I didn't suggest it.

To my suggestion of a way that required updating, Paul said,

| More work.  Feh.

Exactly.  That's why, I'm guessing, you weren't doing it that way all along.

When I wondered,

But what would happen if I used

 leave-isp-\/(colo|colonoscopies|webhosting|equipment)

instead?  Would messages from the colonoscopies list be matched to "colo"

Paul replied,

| I don't have a login at ieee.org, so I can't browse the interpretations
| database, but I'm pretty sure that 1003.2 defines only *whether* a
| regexp will match, and any parsing of the regexp to identify its parts
| (besides backreferences to atoms in brackets) would be implementation-
| specific (as it is in procmail).  If that's the case, then the correct
| answer is "mu".

What matters is what procmail does, not what it should do nor what ieee.org
expects.  I ought to try it out for myself.

| How's that for a long way to say "I don't know"?  ;-)

I've heard longer.

| Note the OS-independent sed script.

Noteworthy it was indeed.

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