Don Hammond <procmail(_at_)tradersdata(_dot_)com> writes:
On 25 Oct, Paul Chvostek wrote:
|
| [...]
|
| Is there a defined "order of operations" for procmail conditions? It
| would seem to me that "()\/one|two|three" might save "one" to MATCH, but
| not "two" or "three", but "()\/(one|two|three)" would populate MATCH for
| all three. Is the \/ parsed before the |? Does it matter?
|
Although your guess may be intuitively logical, a simple test proves
otherwise.
Unfortunately, your test runs afoul of a bug in procmail regexp engine
that causes it to sometimes set MATCH incorrectly. As I understand it,
this only occurs when the \/ token can be the first token matched,
or if there is a superfluous 'match anything' subregexp before the \/
token.
The match token acts** like it has high precedence. If you want an
alternation (OR expression) on either side of it, you need parens
around them.
** I say "acts like" because it doesn't really have precedence. It's a
token like '.' and '\<', not a operator like '|' or '*', so it doesn't
really have precedence. The precedence of concatenation over alternation
is what makes it work the way it does.
---(cut here: zrc)---
DEFAULT=/dev/null
VERBOSE=no
NL="
"
VAR=two
MATCH # unnecessary except to prove point
:0
* VAR ?? ()\/one|two|three
{ LOG="$VAR matched ()\/one|two|three; MATCH=$MATCH$NL" }
MATCH # unnecessary except to prove point
:0
* VAR ?? ()\/(one|two|three)
{ LOG="$VAR matched ()\/(one|two|three); MATCH=$MATCH$NL" }
---(cut here: zrc)---
Add the following and try again:
MATCH # HITS BUG
:0
* VAR ?? zero|\/one|two|three
{ LOG="$VAR matched zero|\/one|two|three; MATCH=$MATCH$NL" }
MATCH # MISSES BUG
:0
* VAR ?? (^|.)\/one|two|three
{ LOG="$VAR matched (^|.)\/one|two|three; MATCH=$MATCH$NL" }
VAR="foo two"
MATCH # MISSES BUG
:0
* VAR ?? .\/one|two|three
{ LOG="$VAR matched .\/one|two|three; MATCH=$MATCH$NL" }
MATCH # MISSES BUG
:0
* VAR ?? foo \/one|two|three
{ LOG="$VAR matched foo \/one|two|three; MATCH=$MATCH$NL" }
Philip Guenther
Procmail Maintainer
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail