delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/19/15:18:32

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 19 Aug 2005 15:18:18 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Poor Yorick <com DOT cygwin DOT cygwin AT pooryorick DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: bash test -n && test -z return tru
In-Reply-To: <43062C7F.8010906@pooryorick.com>
Message-ID: <Pine.GSO.4.61.0508191510080.16057@slinky.cs.nyu.edu>
References: <43062C7F DOT 8010906 AT pooryorick DOT com>
MIME-Version: 1.0

On Fri, 19 Aug 2005, Poor Yorick wrote:

> from reading the bash man pages, I would have thought the -n and -z were
> mutually exclusive.  Therefore I don't understand this result:
>
> ~>$ [ -n $(which nonexisingfilename 2>/dev/null) ] && [ -z $(which nonexistingfilename 2&>/dev/null) ]  && echo hello
> hello
> ~>$
>
> can anyone help explain this?

I think when -n and -z aren't given a parameter, the results are
unspecified.  You need to quote the output of $(which...):

$ [ -n "$(which nonexisingfilename 2>/dev/null)" ] && [ -z "$(which nonexistingfilename 2&>/dev/null)" ] && echo hello
$

HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019