On Tuesday, 26 February 2013 at 07:16:34 UTC, Jonathan M Davis
wrote:
On Tuesday, February 26, 2013 08:08:33 Lars T. Kyllingstad
wrote:
What if the variable is set, but empty? Is that very different
from the situation where it doesn't exist at all? In my
opinion,
when it comes to environment variables, no.
And yet, there _is_ a difference. I've dealt with code before
that simply cared
about whether an environment variable was set and not at all
what it was set
to. Regardless of whether that's desirable behavior, any
program that needs to
be compatible with a program that follows that behavior will
need to be able
to follow that behavior as well. So, if std.process is set up
so that you
can't tell the difference betwen an environment variable which
hasn't been set
and one that's been set to nothing, then that's a problem, even
if it's not
the most common case.
You can tell the difference. In the former case
environment.opIndex() will return null, in the latter it will
return "". Use 'is null' to determine which.
Lars