Merrill,
I've added a environment::variable-exists(string) function to cvs. The
environment::get-variable function will now report an error when attempting
to get the value of an environment variable that doesn't exist.
Gert
----- Original Message -----
From: "Merrill Cornish" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 06, 2004 9:54 PM
Subject: [Nant-users] Checking for non-existent environment variable
> 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-confignam
e'))=''}">
>
> 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
>
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users