Re: wrong logical evaluation of expressions involving true or false commands

2007-06-26 Thread Matthew Woehlke
Paul Jarc wrote: Matthew Woehlke [EMAIL PROTECTED] wrote: Stephane Chazelas wrote: [ -n $foo -a -n $bar ] is not the expression to test whether both $foo and $bar are non-empty, as it would fail for some specific values of $foo or $bar (try it when $foo contains = for instance). Huh? Why

wrong logical evaluation of expressions involving true or false commands

2007-06-25 Thread Miguel Ángel
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='p$ uname output: Linux hal 2.6.20-16-generic #2

Re: wrong logical evaluation of expressions involving true or false commands

2007-06-25 Thread Bob Proulx
Miguel Ángel wrote: Evaluating expressions like: [ true -a false ] ; echo $? always returns 0 (true), doesn't mind if I change true for false or viceversa. In the case of the test operator (aka '[ expr ]') use of true and false as you have done are strings and not boolean expressions and not

Re: wrong logical evaluation of expressions involving true or false commands

2007-06-25 Thread Stephane Chazelas
On Mon, Jun 25, 2007 at 02:07:56PM -0600, Bob Proulx wrote: [...] following. These are the same. [ foo -a bar ] [ -n foo -a -n bar ] This is defined by standard by the number of arguments. http://www.opengroup.org/onlinepubs/009695399/utilities/test.html [...] And it should be

Re: wrong logical evaluation of expressions involving true or false commands

2007-06-25 Thread Matthew Woehlke
Stephane Chazelas wrote: And it should be noted (and it's noted as well in the page you're refering to) that while the above is true for strings such as foo and bar, it is not true in the general case. [ -n $foo -a -n $bar ] is not the expression to test whether both $foo and $bar are

Re: wrong logical evaluation of expressions involving true or false commands

2007-06-25 Thread Paul Jarc
Matthew Woehlke [EMAIL PROTECTED] wrote: Stephane Chazelas wrote: [ -n $foo -a -n $bar ] is not the expression to test whether both $foo and $bar are non-empty, as it would fail for some specific values of $foo or $bar (try it when $foo contains = for instance). Huh? Why would having an '='