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

Blair Zajac blair at orcaware.com
Mon Aug 30 16:29:19 PDT 2004


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/




More information about the Orca-users mailing list