Problem with $VAR -eq ''

Jun 1, 2015 at 9:25 PM
Edited Jun 1, 2015 at 9:27 PM
Hello Kine,

i suspect the syntax $ENV:NAVIdePath -eq '' does not work in every case.

I tested this statement:
 $ENV:NAVIdePath = ''
if($ENV:NAVIdePath -eq '') {            
    Write-Host "Null"            
} else {            
    Write-Host "Full"            
}

if (!$ENV:NAVIdePath) 
    { Write-Host "Nill" } 
    else 
    {Write-Host "Fill" }
Result:
Full
Nill

I debugged the source and found later this link.
http://www.thomasmaurer.ch/2010/07/powershell-check-variable-for-null/

Greetings Erik
Coordinator
Jun 2, 2015 at 6:15 AM
I Agree. This code was written when I didn't know how to test variables to some values. Should be the second variant.

Fixed in commit 1f6bc6cf5042c