procmail
[Top] [All Lists]

Re: Boolean condition?

2002-01-10 11:22:39
John Conover asked,

| How do you do a strict boolean condition? Something like
|
| VAR="true"
|
| :0
| * $${VAR:+!}
| folder
|
| which would file the message in folder if VAR is set.

Not if it isn't also null!  That recipe will file the message if the
variable is set but null, or if it's unset.  It won't file the message if
the variable is set and non-null.

If you want to file a message only if a variable is set,

 :0: # no second colon if folder is a directory
 * $ ! ${VAR+!}
 folder

Sean Straw wrote,

or, if you want to check for it being set AT ALL:

* ! SOMEFLAG ?? ^^^^

No, that will check for its being non-null.  If the variable is set but
null, that kind of test will treat it the same as if it were unset.

To answer John's original question, I'd need more details.  But for
starters:

# to match if the variable is set
* $ ! ${VAR+!}

# to match if the variable is unset
* $ ${VAR+!}

# to match if the variable is unset or null
* $ ${VAR:+!}
# or
* VAR ?? ^^^^

# to match if the variable is set and non-null
* $ ! ${VAR:+!}
# or
* ! VAR ?? ^^^^
# note that  * VAR ?? .  is wrong because it will fail if $VAR
# is set and non-null but contains only a newline or a string
# of newlines, but in its own inefficient way, this will work,
# allowing for our old friends, the putative newlines:
* VAR ?? .|$($)$

# to match if a variable is set but null
* $ ! ${VAR+!}${VAR:+!}



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