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? W
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" a
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 shou
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 a
'help test' says that an expression consisting of a single string is an alias
for "-n STRING" which is "true if the string is not empty." So, [ false -a
false ] and [ false ] are true because "false" is a non-empty string. [ "" ] is
false.
You probably just want 'true && false' without the [.
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 SM
Configuration Information [Automatically generated, do not change]:
Machine: amd64
OS: freebsd6.2
Compiler: cc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='amd64'
-DCONF_OSTYPE='freebsd6.2' -DCONF_MACHTYPE='amd64-portbld-freebsd6.2'
-DCONF_VENDOR='portbld' -DLOCALEDIR='/usr/local/share/
Configuration Information [Automatically generated, do not change]:
Machine: amd64
OS: freebsd6.2
Compiler: cc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='amd64'
-DCONF_OSTYPE='freebsd6.2' -DCONF_MACHTYPE='amd64-portbld-freebsd6.2'
-DCONF_VENDOR='portbld' -DLOCALEDIR='/usr/local/share/