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

Dmitry Berezin dberezin at surfside.rutgers.edu
Wed Sep 1 09:12:57 PDT 2004


Actually no. The string consisting of 2 spaces is not considered empty, and
if you "quote" it, test -z will return false. The "feature" that I was
trying to use is that in some (as it appears, not all) implementations test
-z returns true if argument is missing, and when you don't quote an _empty_
or _blank_ string, shell just strips off those "extra" spaces. In fact, test
-n also returns true if argument is missing (so it becomes quite confusing).

 

# a="  "

# if [ -z $a ]; then echo empty; fi

empty

# if [ -n $a ]; then echo empty; fi

empty

# if [ -z "$a" ]; then echo empty; fi

# if [ -n "$a" ]; then echo empty; fi

empty

 

As I said, forget it - bad idea.

 

  -Dmitry.

 

-----Original Message-----
From: David Michaels [mailto:dragon at raytheon.com] 
Sent: Tuesday, August 31, 2004 4:09 PM
To: Dmitry Berezin
Subject: Re: [Orca-users] orca 0.27 make error on Solaris 9

 

So, in bash and ksh, a string consisting of 2 spaces is considered 'empty'
(per -z)?  Isn't that broken?

Dmitry Berezin wrote:



And even if it was reliable, it doesn't take care of the problem with a
variable set to N spaces, which is a side-effect of the formatting of
the Makefile where the variable in question is defined (using \ to span
lines, and tabs/spaces to separate values of two other variables).
    

 
Well, actually it would. That's why I suggested that approach on the first
place. It works with bash and with "[ ]" version of "test" in ksh.
Unfortunately, it's not "really" portable :-(
 
  -Dmitry.
 
  

 

-- 


 

Raytheon

 


 

David P. Michaels

Senior Multi-Disciplined Engineer II W.H.

NPOESS IS
Platform OS Unix
303.344.6840
720.858.5952 fax
720.521.0561 pager

 <mailto:dragon at raytheon.com> dragon at raytheon.com

aka "Dragon" 

"I wonder what news is doing..."
 
 news at newshost <29> ps -fu news      
 news 18624 12367 2 0:00 makehistory 
 
"News is making history."
      

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/orca-users/attachments/20040901/b6595158/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 481 bytes
Desc: not available
URL: </pipermail/orca-users/attachments/20040901/b6595158/attachment.gif>


More information about the Orca-users mailing list