procmail
[Top] [All Lists]

Re: Self-Modifying .procmailrc

1997-10-09 09:59:36
Jari Aalto posted some very long code, and though I just skimmed it and have
no comment on Jari's general logic and procedures, this stuck out:

|     :0c
|     * address ?? [^ \n\t]+@
|     | echo "$address" > $JA_FWD_FILE

First, procmail doesn't understand \n or \t; they are the same as n and t to
procmail.  Second, a bracketed range, inclusive or exclusive, will never
match a newline, so you don't have to specify "no newlines".  Third, there's
no gain (since we are not extracting) in the plus sign there; if there are
one or more acceptable characters before the at-sign, there is one, and vice
versa.  Fourth, the action of that recipe doesn't use any text from the
message, so it needs an `i' flag.

      :0c
      * address ?? [^   ]@
      | echo "$address" > $JA_FWD_FILE

Fifth, that technically needs a local lockfile (which, in turn, needs to be
named, as there is nothing to help procmail to infer a name), but the write
of just $address and a newline is likely to be short enough that we can get
away without one.

These caught my notice as well:

| *$ ? test -s $JA_FWD_FILE
| *$ ? test -r $JA_FWD_FILE

"?" exit code conditions are subjected to variable expansion automatically,
so the "$" modifier in front is superfluous (but harmless, as long as it
precedes the question mark).  In fact, this other condition gets along fine
without it:

|    * ? test -e $JA_FWD_FILE

but it has its own problem: not all versions of test understand "-e"; it's
better to use "-f" or "-r".

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