procmail
[Top] [All Lists]

set but null

2003-09-20 16:58:28
I said that the way to test whether a variable is set but null is,

: * $ !${VAR+!}${VAR:+!}

Dallman requested an explanation.  OK.

The condition asks for $-interpretation, so let's $-interpret it.

${name+text} becomes "text" if $name is set; otherwise it's nothing.
${name:+text} becomes "text" if $name is set and not null; otherwise
it's nothing.

So if VAR is unset, the exclamation point outside the braces stays an
exclamation point.  The two substitutions are both nothing, so the
condition interprets to

 * !

which is always false.

If VAR is set and non-null, the first exclamation point stays as it is,
but both braced expressions become exclamation points.  So we have

 * !!!

which is likewise always false.

If VAR is set but null, the first exclamation point is never affected,
the first substitution is another exclamation point (because VAR is
set), but the second substitution is nothing (VAR is not non-null), so
we have

 * !!

which is always true.

> That all must have happened in the circa nine or ten months that
> transpired three years ago when I was not following this list, I'm
> afraid.  Other than that period, and perhaps one other of around the
> same length, I've been here for ten years.  But I have absolutely no
> recollection of that. If it was more recently, it may have zoomed
> right over my head, anyway; and sometimes I don't have time for more
> than skimming here.

I think it was longer ago than that.


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