procmail
[Top] [All Lists]

Re: proper use of metamail & procmail

2001-03-08 00:49:33
Holger suggested to Timothy,

W> You could, why let that part get into $MATCH in the first place?

W>         :0 fbw
W>         * ^Content-Type: *\/[^;]+
W>         | metamail -qbc $MATCH

W> just reads everything up to the semicolon into $MATCH, no need to cut
W> anything off afterwards.

and Timothy asked,

L> But there is not always a semicolon there.
L> Is there a way to make that optional?

It already is.

To the right of an extractor ("\/"), wildcards in procmail regexps are
greedy.  So [^;]+ will match as many characters that it can find that are
neither semicolons nor newlines.  If there's no semicolon in the field,
procmail will extract the entire remainder of the line (where the newline
will stop it).  If there is a semicolon later in the line, the semicolon (or
the first of them if there are two or more) will stop the extraction.

Actually, the code as it stands will happily assign zero spaces to " *"
(wildcards in procmail regexps are stingy to the left of [or in the absence
of] an extractor) and include any spaces in $MATCH.  What we need is more
like this:

         :0 fbw
         * ^Content-Type: *\/[^ ;]+
         | metamail -qbc "$MATCH"

The quotes around $MATCH may never be needed, but they'd make me feel safer.
If spaces are allowed in the value of $MATCH, we certainly need the quotes,
and then the recipe should look like this:

         :0 fbw
         * ^Content-Type: *\/[^ ;][^;]*
         | metamail -qbc "$MATCH"

_______________________________________________
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>