The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

gearoid (1) [Avatar] Offline
#1
In Unix scripts I can test a shell/environment variable thus:

if [ "$ENVVAR" = "" ]
then
...
fi

This evaluates to TRUE if the variable does not exist or if it has no assigned value.

I find I cannot set an environment variable to the empty string using PowerShell on Win2000. Further no distinction is made between $ENVVAR and $EnvVar -- they are returned in UPPERCASE.

I have not found any documentation on this theme yet (although I am reading the In Action book at the moment).

Example:

PS> $env:myvar=""
PS> Get-ChildItem | Sort-Object -property name
...
lists current environment variables and their values but not "myvar"
Yet no error is thrown.

Any information welcome.