This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: bash test -n && test -z return tru
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: Poor Yorick <com dot cygwin dot cygwin at pooryorick dot com>
- Cc: cygwin at cygwin dot com
- Date: Fri, 19 Aug 2005 15:18:18 -0400 (EDT)
- Subject: Re: bash test -n && test -z return tru
- References: <43062C7F.8010906@pooryorick.com>
- Reply-to: cygwin at cygwin dot com
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@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.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/