At 14:40 2003-07-05 -0600, LuKreme (List User Kreme) wrote:
Someone is going to revoke your title of His Kreminess is you keep doing
that.
I have a title? I mean, I knew about Kitchen Staff Supervisor, but this
new title is news. Does it come with benies?
Well, the title varies. The Kremey One is a fave. As with all titles,
it's in leiu of benefits.
Checking your original post, I note that the syntax you're using implies
that you're probably chaining a series of list identification recipes,
probably with :0E for the flag line on each. There's an alternative, which
can be a lot less painful if you have a lot of lists and ever need to run
VERBOSE logging. Let's assume that the existing recipes (following the
generic list identiciation rule) look something like:
:0E
* specific rules for yet another list
{
LISTNAME=thislist
}
You could put the heart of the mkdir/deliver rule into a separate rcfile,
then change recipes of the above form to:
:0
* specific rules for yet another list
{
LISTNAME=thislist
INCLUDERC=list-deliver.rc
}
As an added level of protection against inadvertent inclusion, the
list-deliver.rc file could still include the check for a NULL LISTNAME, so
that it doesn't attempt to deliver when you fail to define LISTNAME before
including it.
Further, this all works well with the suggestion which David provided,
wherein you attempt the write, and if it fails, THEN you create the dir and
try again. Change the list-deliver.rc to (or something like it):
:0
* ! LISTNAME ?? ^^^^
{
:0:
$MLDIR/$LISTNAME/$MONTHFOLDER.$LISTNAME
# If it's delivered, it's delivered (and procmail won't be parsing
# past the above line). If it failed, it's probably because the
# directory didn't exist, so try creating the dir and writing again.
:0eW
DUMMY=| mkdir -p $MLDIR/$LISTNAME
# if mkdir succeeded, store the message now
:0a:
$MLDIR/$LISTNAME/$MONTHFOLDER.$LISTNAME
}
DUMMY=`test -d $MONTHFOLDER || mkdir $MONTHFOLDER`
it's short, it's obvious what it's doing, it's simple. Elegant, maybe.
But, the -p option to mkdir is shorter, perhaps even slightly more
efficient (on the various systems I checked, the mkdir binary is even
marginally SMALLER than test). This syntax (which you used in your
original post) is in both the POSIX and GNU versions. Additionally, this
ignores options which corresponds to existing directories, meaning that the
test operation isn't really required.
I would suggest that you change your NEWDIR variable out to DUMMY, just so
that it is clear that the string isn't significant (unless you're using it).
As for being obvious as to what it's doing, stating that you're making the
directory, is pretty obvious - the -p option might be as obvious to someone
as the 'test -d' is, and there's one less manpage to check if you don't
know that it is. <g>
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail