procmail
[Top] [All Lists]

Re: Obscure procmail oddities

1998-07-16 17:28:25
Walter Dnes wrote,

| According to "procmail -v" my ISP is running procmail
| v3.11pre4 1995/10/29.  Here are a couple of esoteric items
| I've run into.  I don't know if these have anything to do
| with my ISP's setup, but I haven't seen them in any man
| pages...

There's nothing obscure about them.

| 1) INCLUDERC command is case-sensitive.  includerc is *NOT*
|    the same as INCLUDERC.  I.e. the line...
|    includerc=filename
|    ..sets a var named "includerc" to a value "filename".  It
|    does *NOT* call "filename" like INCLUDERC does.  I didn't
|    test this out, but I wonder if other keywords like
|    LINEBUF, LOGFILE, DEFAULT, etc, are also case-sensitive.

Yes, every single one is case-sensitive, just as with the names of shell
variables.  [In my own .procmailrc I use $LIST and $List as two *different*
variables with different values, and procmail never confuses the two (though
I might, so normally it's not a good idea).]  I doubt that the man pages
point it out, as it is something that people are expected to know.

| 2) The special variable $$ returns the process ID of the
|    current procmail instance.  E.g...
|    LOGFILE=LOG.$$
|    ...opens a logfile with root "LOG" and an extension that
|    equals the PID, e.g. "LOG.22074"
|    If this works for everyone, it would be very useful in
|    situations where an instance of procmail needs to have a
|    unique scratch filename, or simply a unique "anything".

That is mentioned specifically in the procmailrc(5) man page.

Like other special variables, $$ has a quirk: it works fine in naming other
variables, or in specifying folders or directories to save to, or in speci-
fying a lockfile name, or in a command that doesn't invoke a shell, but in
a command that *does* require a shell, the shell that runs it will use its
own value of $$ (which will be its own process ID), and it won't match that
of the procmail invocation that calld it.  To get around that, I do this:

 PID=$$

and then I use $PID instead of $$.  Procmail exports all regular variables,
so when a shell uses $PID it imports the value from procmail.

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