procmail
[Top] [All Lists]

Re: Filter Order in Procmailrc

1997-09-19 08:43:48
Ed James asked about Era Eriksson's explanation of the HOST variable,

| Thank you.  Now I would like to know what it is useful for. 

It goes back to the early days of procmail, before Stephen thought of
INCLUDERC or the "var ?? condition" syntax.  When people had to use different
code based on which local host machine was processing a particular message,
the method was to list a number of rcfiles on procmail's command line.  The
first one would start out with general code for all messages and all hosts
and then have a 

      HOST=some.specific.machine

assignment, followed by code for mail delivered on that machine.  If the
first nine characters of "some.specific.machine" matched the real value
of $HOST, procmail would stay in that rcfile; on a mismatch, it would jump
to the second rcfile named on the command line.

The second rcfile would probably be for another particular machine, so
(unless it first had some universal code for all machines except the first
one, or unless there were only two machines where procmail might run) right
at the top it would have

      HOST=this.specific.machine

Again, a match for the first nine characters would keep procmail reading this
rcfile, but a mismatch would make it jump to the next rcfile.

And so it went.  An incorrect HOST assignment (note that "HOST" alone at-
tempts to unset the variable, so it is *always* an incorrect assignment) in
the last rcfile on the command line made procmail drop the message and exit.
Since we almost never name more than one rcfile on the command line now, at-
tempting to unset HOST in .procmailrc will have that effect.

I would guess that the only use of this original setup still around is in
SmartList, where flist invokes procmail with a number of rcfiles on the
command line and uses things like HOST=go.to.the.next.rcfile.now to move from
one to the next.  Also, procmail's -m facility (which didn't exist back then)
is incompatible with using HOST to jump among rcfiles, because it requires
naming exactly one rcfile on the command line.

Nowadays we can do something like this to use different rcfiles on different
hosts:

  :0
  * HOST ?? ^^\/[^.]+
  { INCLUDERC = $HOME/.$MATCH.rc }

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