procmail
[Top] [All Lists]

Re: recursive INCLUDERC tricks - dirname.rc

1997-10-09 09:45:50
Dan Smith wrote,

| For a number of weeks, the following comment from my "spamcheck" has
| been bothering me
|    # needs to be set for INCLUDERC.  Is there a way to get it from $_ ?
|    SPAMCHECK_RCDIR=${SPAMCHECK_RCDIR:-$RCDIR/spamcheck}
| that is I want to do
|    this_rcfile=$_
|    SPAMCHECK_RCDIR=`dirname $this_rcfile`
| but without having to leave procmail.  Well, today I figured out how
| to do this by using a recursive INCLUDERC file.

It shouldn't need a recursive INCLUDERC.

  this_rcfile=$_

# This next recipe may be unnecessary; perhaps $_ always is a full path:

  :0
  * ! this_rcfile ?? ^^/
  { this_rcfile=$MAILDIR/$this_rcfile }

  :0
  * this_rcfile ?? ^^\/.+/
  { dirname=$MATCH }

If you need to strip the trailing slash, add this:

  :0
  * dirname ?? /^^
  * dirname ?? ^^\/.*[^/]
  { dirname=$MATCH }

In current versions of procmail, the last two can be combined:

  :0
  * this_rcfile ?? ^^\/.+/
  * MATCH ?? ^^\/.*[^/]
  { dirname=$MATCH }

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