procmail
[Top] [All Lists]

Re: Defining a common set of actions ?

1997-05-21 14:11:00
Pascal Dupuis wrote,

| My setup (procmailrc)
| :0
| * some test
| | procmail  -p $HOME/dir/rc.action
| :0
| * some other test
| | procmail  -p $HOME/dir/rc.action

| But, instead of recursively being processed, selected mails are saved to
| a folder called "| procmail -p $HOME/dir/rc.action" !

Now that is very strange, unless you are enclosing the action line in
quotes, or you altered the source code before compiling procmail, or you
are not using the full action line but have saved it in a variable and
are using just the variable there.

| Does the new invocation inherit from all variables set in the parent ?

Most of them: check the procmail(1) man page for full details on what -p
will and will not pass.  There is a better approach, though.

| Could I put the string "| procmail  -p $HOME/dir/rc.action" into some
| variable ?

Yes, but its expansion would be treated as a folder name, and that's not what
you want.

A much better way is

  :0
  * some test
  { INCLUDERC=$HOME/dir/rc.action }
  :0
  * some other test
  { INCLUDERC=$HOME/dir/rc.action }

Just make sure that $HOME/dir/rc.action results in final delivery so that
execution will not return to $HOME/.procmailrc.  (And indeed it currently
does, though I'd suggest a local lockfile on its save to $DEFAULT unless
$DEFAULT points to a directory.)

This way there is no need to fork another instantiation of procmail, and
*all* environmental variables will remain in effect while procmail reads
$HOME/dir/rc.action.

It would be better yet if you can possibly combine the two tests; for
example, if they are both (non-negated) regexps,

  :0
  * some test|some other test
  { INCLUDERC=$HOME/dir/rc.action }

If they cannot be combined into a single condition, then you can OR them
this way (among yet other ways as well, but this is my recommendation):

  :0
  * ! some test
  * ! some other test
  { }
  :0E
  { INCLUDERC=$HOME/dir/rc.action }

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