procmail
[Top] [All Lists]

Re: procmail to Maildir as read?

2000-10-21 12:46:06
MaD dUCK <madduck(_at_)madduck(_dot_)net> writes:
with a little bit of tweaking, this does exactly what i want:

<snip>
INBOX=$MAILDIR/inbox/

:0 c
$INBOX

:0 ai
* LASTFOLDER ?? ()\/[^/]+^^
| mv `echo $LASTFOLDER | sed -e 's/\/tmp\//\/new\//g'` "$INBOX/cur/$MATCH:2,S"
</snip>

i don't know this LASTFOLDER ? () ... wizardry so i defaulted to sed - maybe
someone can translate that to me. problem is that LASTFOLDER is set to two
arguments, the first being the message as it was written to ./tmp, the second
as it was written to ./new. i want mv to access the one in ./new and move it
to ./cur with the given postfix.

Since when has LASTFOLDER contained both of them?  Testing with procmail
versions 3.14 and 3.15 (the only ones that support maildir format)
I get only the path to the file in /new in the LASTFOLDER variable.
What version are you running?


Wait a moment: if what you say is true (LASTFOLDER contains two paths)
then the command you show wouldn't work: mv would be getting three
arguments.  Let's back up a step: what makes you think LASTFOLDER contains
two paths?


And finally, _please_ stop the leaning toothpick disease!  Don't use /s
as the separator in sed commands when working with paths!  Compare:
        echo $LASTFOLDER | sed -e 's/\/tmp\//\/new\//g'
        echo $LASTFOLDER | sed -e 's:/tmp/:/new/:g'
You can use almost any character to separate the parts of a 's'ubstitute
command, so please avoid the ones that make it hard to read.



and while we are at it... how does this FOLDER ?? () ... hacking work again?

To quote the procmailrc(5) manpage:
       There are some special conditions you can use that are not
       straight regular expressions.  To select them, the  condi\xAD
       tion must start with:
...
       variablename ??
            Match the remainder of  this  condition  against  the
            value of this environment variable (which cannot be a
            pseudo variable).  A special case is if  variablename
            is equal to `B', `H', `HB' or `BH'; this merely over\xAD
            rides the default header/body search area defined  by
            the initial flags on this recipe.

So, the condition
        * LASTFOLDER ?? ()\/[^/]+^^

matches the regexp "()\/[^/]+^^" against the variable LASTFOLDER.
That regexp extracts all the non-slash characters at the end of the value
(requiring at least one to be there) into the variable MATCH.


Philip Guenther

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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