procmail
[Top] [All Lists]

Re: What is the difference?

2002-10-08 00:49:10

On Mon, Oct 07, 2002 at 10:48:43PM -0700, Robin Lynn Frank wrote:

MAILDIR=$HOME/Mail
...
MAILDIR=${HOME}/Mail

Can someone give me a hint as to what the difference is, if any?

The curly braces work in procmail the same way they do in a shell.  They
identify that the stuff inside is the name of the variable, and the
stuff outside is not.  The first format will work *unless* you need to
follow the variable with text that can be interpreted as part of a
variable name (i.e. alphanumeric or underscore).

For example, let's say you're subscribed to a number of FreeBSD mailing
lists, and you want procmail to sort them into folders upon delivery.
Rather than having a separate rule for each list, you might use:

 :0:
 * ^Sender: owner-freebsd-\/(_dot_)*(_at_)FreeBSD(_dot_)ORG
 * MATCH ?? ^\/[^(_at_)]+
 ${MATCH}_freebsd

This would make local folders like current_freebsd and security_freebsd,
etc.  If you were to use $MATCH_freebsd instead of ${MATCH}_freebsd as
your action line, it wouldn't work, because without the braces, procmail
would try to expand a variable named MATCH_freebsd rather than the
variable MATCH followed by the literal text "_freebsd".

The braces are redundant in your spambouncer example, but using them
unnecessarily is not considered a bad habit.

-- 
  Paul Chvostek                                             
<paul(_at_)it(_dot_)ca>
  Operations / Abuse / Whatever                          +1 416 598-0000
  it.canada - hosting and development                  http://www.it.ca/

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