Amanda-Users

Re: Another oddity from Gene

2009-10-19 12:42:07
Subject: Re: Another oddity from Gene
From: Nathan Stratton Treadway <nathanst AT ontko DOT com>
To: amanda-users AT amanda DOT org
Date: Mon, 19 Oct 2009 11:40:39 -0400
On Mon, Oct 19, 2009 at 10:57:16 -0400, Dustin J. Mitchell wrote:
> The whitespace is significant in the command I showed:
> 
> if [ `/bin/ls /dumps` != "" ]
> 
> btw, the shell strips leading and trailing whitespace, so don't worry
> about the newline.

However, if /dumps is empty, the above will return a parse error (at
least in bash) since
  `/bin/ls /dumps`
will be blank and so no string will be found on the left side of the !=
after command subsitution.

Putting double quotes around it the invocation of ls seems to work both
when /dumps is empty and when it isn't:
  if [ "`/bin/ls /dumps`" != "" ]

                                                Nathan

----------------------------------------------------------------------------
Nathan Stratton Treadway  -  nathanst AT ontko DOT com  -  Mid-Atlantic region
Ray Ontko & Co.  -  Software consulting services  -   http://www.ontko.com/
 GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt   ID: 1023D/ECFB6239
 Key fingerprint = 6AD8 485E 20B9 5C71 231C  0C32 15F3 ADCD ECFB 6239

<Prev in Thread] Current Thread [Next in Thread>