procmail
[Top] [All Lists]

Re: Message tag suffix

1997-09-03 19:35:14
When Robert Gahl wrote,

G> I was just going to use procmail's "unique-o-fier" rather than just
G> write my own. I was hoping that that unique key it generated was
G> directly accessible rather than stripping it off of LASTFOLDER.

No need for the past progressive; stripping it off LASTFOLDER is a trivial
procedure that can be done within procmail, as Ed Sabol has already posted:

S>    :0
S>    * LASTFOLDER ?? backup/\/.+
S>    { MSGPREFIX = $MATCH }

Well, MSGPREFIX is a reserved variable that we shouldn't clobber, but you
can call it BASENAME or something like that.

S> Or, if you don't want to rely on the directory always being named "backup",

S>    :0
S>    * LASTFOLDER ?? ()\/[^/]+$
S>    * MATCH ?? ^^\/.+
S>    { MSGPREFIX = $MATCH }

As I discussed when similar code came up in another thread, I don't think
that the trailing newline will cause a problem, and the second condition
is likely unnecessary:

    :0
    * LASTFOLDER ?? /\/[^/]+$
    { BASENAME = $MATCH }

Ed also suggested,

S> But if you're just want some string to uniquify what you are doing, you might
S> be able to just use $$ (the process ID number). That's much easier and,
S> assuming the need for the uniquifying string is short-term, probably just as
S> good as using the backup filename.

One extreme caution about that: if you use $$ in a procmailrc action that
invokes a shell, the shell will substitute its own PID for "$$" instead of
procmail's.  (The same will happen with $- but not with the named form
$LASTFOLDER.)  The workaround is to assign

  PID = $$

in the procmail rcfile before using it in an action line; then refer to it
as $PID.

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