I have used NAnt 0.84 for months.  Now I am experimenting with 0.85 using the 
nant-0.85-20040705.zip nightly build.

I need to determine whether an environment variable is set or not.  If I do

     <echo message=""|${environment::get-variable('XYZ')}|"/>


where environment variable XYZ does NOT exist, then it prints ||, which implies that 
the value of the function is the empty string.  However, if I do

    <if test="${environment::get-variable('XYZ') = '' }">
        <echo message="env not defined"/>
    </if>

which would appear to compare the function result against an empty string, NAnt bombs 
out with a null reference exception along with a plea to send a bug report to 
nant-developers.

OK, so maybe the value of the function is null rather than the empty string, but if 
so, how do you compare (safely) against null?

I eventually found that 

     <if 
test="${convert::to-string(environment::get-variable('FEATURETESTS-configname'))=''}">

would work.  convert::to-string() apparently accepts null inputs and output an empty 
string.  But this seems rather verbose for simply checking to see if the environment 
variable is not set.

Merrill


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to