procmail
[Top] [All Lists]

Re: substituting for dirname

1998-02-08 23:51:21
dattier(_at_)wwa(_dot_)com (David W. Tamkin) writes:
Timothy Luoma had an answer for Chris Mason, which included this:

|      DIR=`dirname ${MBOX}`

Procmail can do that without forking dirname.

:0
* MBOX ?? ^^\/.+/
{
 DIR=$MAILDIR/$MATCH

 :0ic
 * ? test ! -d "$DIR"
 | mkdir -p "$DIR"
}


Beware: there apparently are OSes on which a trailing slash will cause
mkdir to fail -- they interpret a missing path component as ".", and
"mkdir foo/." doesn't work.  If you're so lucky as to have to work on
such an OS, you'll need to add another condition line to the above
recipe in order to zap the trailing slash:

        :0
        * MBOX  ?? ^^\/.+/
        * MATCH ?? ^^\/.*[^/]
        {
            DIR=$MAILDIR/$MATCH
        
            :0ic
            * ? test ! -d "$DIR"
            | mkdir -p "$DIR"
        }


Philip Guenther

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