[Orca-users] orca 0.27 make error on Solaris 9

David Devault DDevault at Elance.com
Mon Aug 30 16:54:28 PDT 2004


Blair, 

Are you saying that there are times when the variable could contain "" as its contents?

Here are a few tests from linux and solaris:

#################################################################
LINUX

/bin/sh:
sh-2.05# a="\"\""
sh-2.05# echo $a
""
sh-2.05# 
sh-2.05# 
sh-2.05# if test ! -z "$a";then echo "not empty"; fi
not empty
sh-2.05# if test "`echo $a`" != "";then echo "not eq to \"\" "; fi
not eq to "" 
sh-2.05# if test "`echo $a`" != "\"\"";then echo "not eq to \"\" "; fi
sh-2.05# 


##################################################################################
SOLARIS:

/bin/sh:
[\u@\h: \w]\$ a="\"\""
[\u@\h: \w]\$ echo $a
""
[\u@\h: \w]\$ 
[\u@\h: \w]\$ 
[\u@\h: \w]\$ if test ! -z "$a";then echo "not empty"; fi
not empty
[\u@\h: \w]\$ if test "`echo $a`" != "";then echo "not eq to \"\" "; fi
not eq to "" 
[\u@\h: \w]\$ if test "`echo $a`" != "\"\"";then echo "not eq to \"\" "; fi
[\u@\h: \w]\$ 
[\u@\h: \w]\$ 


-----Original Message-----
From: Blair Zajac [mailto:blair at orcaware.com]
Sent: Monday, August 30, 2004 4:29 PM
To: Adam R Prato
Cc: Dmitry Berezin; orca-users at orcaware.com
Subject: Re: [Orca-users] orca 0.27 make error on Solaris 9


Adam R Prato wrote:

>* Blair Zajac wrote on 30 Aug 2004:
>
>  
>
>>This little test
>>
>>a="    "
>>if test ! -z $a; then
>>       echo not empty
>>fi
>>
>>works fine using /bin/sh on Linux, but with Solaris' /bin/sh, I get this:
>>
>>test.sh: test: argument expected
>>
>>so it doesn't work.  I think the echo is the most portable, easy way to 
>>solve this problem.
>>
>>Regards,
>>Blair
>>    
>>
>
>if test ! -z "$a"; then
>  echo not empty
>fi
>
>That should work everywhere.
>  
>

But then the test doesn't work the way you want it to.  Even if $a is "  
", then the code in the if then fi should not be run.  So using echo 
handles this case.  Another way could be to use case, but then it 
doesn't look as clean in the code.

Regards,
Blair

-- 
Blair Zajac <blair at orcaware.com>
Plots of your system's performance - http://www.orcaware.com/orca/

_______________________________________________
Orca-users mailing list
Orca-users at orcaware.com
http://www.orcaware.com/mailman/listinfo/orca-users




More information about the Orca-users mailing list