Cc:ed back to Procmail-L -- we were off-list for a while here but I
don't think the general audience missed anything :-)
On Sat, 7 Jun 1997 15:53:52 -0700,
rem(_at_)one-o(_dot_)com (Robert E. Maas) wrote:
I have been doing [\[\(] but is that wrong too?
I would imagine so, but of course, nothing beats raw experimentation.
Which reveals that this is in fact the case.
$ cat .prc
MAILDIR=$HOME/scratch
DEFAULT=$HOME/scratch/prc.out
VERBOSE=yeah
:0
* [\[\(]
{ }
:0
* [[(]
{ }
:0
/dev/null
$ echo '\' | procmail .prc
procmail: [9898] Mon Jun 9 09:29:09 1997
procmail: Match on "[\[\(]"
procmail: No match on "[[(]"
procmail: Assigning "LASTFOLDER=/dev/null"
procmail: Opening "/dev/null"
Folder: /dev/null 2
$ echo '[' | procmail .prc
procmail: [29917] Mon Jun 9 09:29:20 1997
procmail: Match on "[\[\(]"
procmail: Match on "[[(]"
procmail: Assigning "LASTFOLDER=/dev/null"
procmail: Opening "/dev/null"
Folder: /dev/null 2
You can verify for yourself that grep behaves similarly.
The explanation, as far as I have one, is that a character class can't
be nested, and always matches exactly one character. So [] doesn't
make sense because it wouldn't match a character, so it must be a
special case. And [[ can't be a nested class so it must mean the [
character itself. As a whole, the rules work to pretty much obviate
the need for backslashes inside character classes. Anything "special"
usually goes right after the opening [ (as does the minus if you want
to match a literal minus).
Free tip: .prc is actually a much larger file I keep around for
experimentation. Every time I wish to try something out I just add it
to .prc and run a couple of tests. Sometimes very revealing.
A similar skeleton file with some brief instructions can be found in
the FAQ I try to maintain at
<http://www.iki.fi/~era/procmail/mini-faq.html>
Hope this helps,
/* era */
--
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r. <http://www.iki.fi/~era/>
* Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>