procmail
[Top] [All Lists]

Re: "sub-routine" in procmailrc

2017-11-10 08:20:58
On Sun, 15 Oct 2017, udi M wrote:

Date: Sun, 15 Oct 2017 18:33:48 +0300
From: udi M <uuddii(_at_)eng(_dot_)tau(_dot_)ac(_dot_)il>
To: procmail(_at_)lists(_dot_)rwth-aachen(_dot_)de
Subject: Re: "sub-routine" in procmailrc

On 09/10/17 19:28, Zhiliang Hu wrote:
 On Mon, 9 Oct 2017, Ruud H.G. van Tol wrote:

>  Date: Mon, 9 Oct 2017 16:50:57 +0200
>  From: Ruud H.G. van Tol <rvtol(_at_)isolution(_dot_)nl>
>  To: procmail(_at_)lists(_dot_)rwth-aachen(_dot_)de
>  Subject: Re: "sub-routine" in procmailrc
> > On 2017-10-09 16:43, Zhiliang Hu wrote: > > > This may be naive but I have not found how to - in procmailrc is it
> >  possible to have a sub-set of rules that can be re-used under certain
> >  conditions? I thought of using separate 'rc' files to "go to" from the
> >  main rc (/etc/procmailrc or ~/.procmailrc); not sure how to implement
> >  the scheme. E.g. Is "incldue" a right way?=A0 Will appreciated any
> >  suggestions.
> > Re. usage of includes, see for example
>  https://rvtol.home.xs4all.nl/procmail/demo/basic/
> > -- Greetings, Ruud

 Thanks! But I guess conditional includes like these would work?

: 0
 * CONDITION A
 INCLUDERC = "$INCDIR/recipesA"

: 0
 * CONDITION B
 INCLUDERC = "$INCDIR/recipesB"

: 0
 * CONDITION C
 {
: 0 c
  INCLUDERC = "$INCDIR/recipesC"

: 0
 INCLUDERC = "$INCDIR/recipesA"
 }
 ?

Yes,  Also, in some cases based on the MATCHing you can do:

: 0
*  theLeftSide\/thePaternYouRlookingFor
{ INCLUDE = $INCDIR/recipes$MATCH }

instead of  case A, case B, etc...

For example:

0:
* Subject: .*simester:[ ]+\/([AB]|Summer)
{ INCLUDE = $INCDIR/simester$MATCH }

I only get time to try it out now - works beautifully! Only something to update the thread:

1. It is "INCLUDERC = rcfile", not "INCLUDE = ...";

2. An alternative "SWITCHRC = another.rcfile" can be very useful also.

Zhiliang

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)rwth-aachen(_dot_)de
https://mailman.rwth-aachen.de/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>
  • Re: "sub-routine" in procmailrc, hu <=