This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bash test -n && test -z return tru


On Fri, Aug 19, 2005 at 03:01:19PM -0400, 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?

This defaults to

  [ -n ] && [ -z ] && echo hello

I would have expected a syntax error in that case.

Regardless of that, however, if you want to actually make this work you
need to do something like:

  [ -n "$(which nonexisingfilename 2>/dev/null)" ]

cgf

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]