procmail
[Top] [All Lists]

Re: User functions in procmail?

1999-03-25 03:58:45
Moe Drippins would like to have something in the direction of

save_and_archive(savefile, archfile)
{
      :0c
      $archfile

      :0A
      $savefile
}


then later, any recipie could do something like:

:0
* ^Subject: .*foo\/.*bar
@save_and_archive($MATCH, arch.$DATE)

:0
* ^TO_ someguy(_at_)thisaddress(_dot_)com
@save_and_archive($HOME/someguy.babblings, $HOME/archive/woot.txt)

Code reuse is possible already with INCLUDERCs, even though the syntax
isn't quite as handy as for such a function call. You can put your
"function" in a file of its own, like this:

--- file $PMDIR/save_and_archive.rc ---
:0
{
        :0 c:
        $SAVE

        :0 A:
        $ARCH
}
--- end ---

and then use it in your examples this way:

:0
* ^Subject: .*foo\/.*bar
{
        SAVE=$MATCH
        ARCH=arch.$DATE
        INCLUDERC=$PMDIR/save_and_archive.rc
}

:0
* ^TO_someguy(_at_)thisaddress(_dot_)com
{
        SAVE=$HOME/someguy.babblings
        ARCH=$HOME/archive/woot.txt
        INCLUDERC=$PMDIR/save_and_archive.rc
}

/HW


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