procmail
[Top] [All Lists]

Re: priorities of ( )

1998-04-29 12:16:04
Timothy Luoma asked,

| If the Header ABC exists then I want to use it, if it doesn't exist then I
| want to use XYZ but I don't ever want to use XYZ if ABC exists in the same
| message

I take it you're extracting; otherwise the question makes no sense.  If
you're not extracting, and both strings are there, it doesn't matter which
one satisfies the condition.

| Right now I have two recipes, which are identical except the first one
| checks for ABC and the second for XYZ
| 
| Will
| 
| * ^(ABC|XYZ)
| 
| always prefer ABC and only use XYZ if ABC doesn't exist, or will it use XYZ
| if it comes first (higher in the headers)?

Again, if you're not extracting, it doesn't matter which.  If you are
extracting, procmail will use whichever occurs earlier in the search area
(not necessarily the one that appears first in the regexp).  If you want to
make it use whichever shows up last in the search area,

 * 1^1 ^\/(ABC|XYZ)

Now, if you want to extract ABC if it is present and XYZ only if ABC is not
there, there are two basic approaches:

  :0
  * ^\/ABC
  action
  :0E
  * ^\/XYZ
  action
or
  :0
  * ! ^\/ABC
  * ! ^\/XYZ
  { }
  :0E
  action

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