Clark, according to the posix standard all three examples are correct,
as it is expected to 'produce unspecified results'. You'd be better
of avoiding the construct.
See the paragraph starting with '3 arguments:' in:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
(Link may require registration.)
$ [ -n hello world ]
is an alternative syntax for calling 'test' with the three arguments
'-n', 'hello', and 'world'.
Henk
On 01/06/2012 07:58, Clark WANG wrote:
For example:
$ echo ${.sh.version}
Version JMP 93u+ 2012-05-17
$
$ [ -n hello world ] && echo yes
yes
$
In Bash I got:
$ echo $BASH_VERSION
4.2.20(1)-release
$
$ [ -n hello world ] && echo yes
bash: [: hello: binary operator expected
$
In Zsh I got:
$ echo $ZSH_VERSION
4.3.12
$
$ [ -n hello world ] && echo yes
[: too many arguments
$
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users