Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Why does builtin 'test' differ from /usr/bin/test
- X-seq: zsh-users 11108
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: zsh-users Mailinglist <zsh-users@xxxxxxxxxx>
- Subject: Re: Why does builtin 'test' differ from /usr/bin/test
- Date: Tue, 9 Jan 2007 08:06:19 +0000
- In-reply-to: <F7507090F1A72B43A51444325DFBE43101723822@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users Mailinglist <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <F7507090F1A72B43A51444325DFBE43101723822@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Sender: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
On Tue, Jan 09, 2007 at 08:38:58AM +0100, Com MN PG P E B Consultant 3 wrote:
> From the zsh manpages:
>
> "test [ arg ... ]
> [ [ arg ... ] ]
> Like the system version of test. Added for compatibility;"...
>
> But in zsh, the following two commands yield different results:
>
> test -a = '-?' -o -a = '?' && echo true # true
> command test -a = '-?' -o -a = '?' && echo true # not true
>
> Why is the first (builtin) test true?
[...]
In short because the behavior of test for more than 4 arguments
is unspecified.
Use:
test -a = '-?' || test -a = '?'
or:
case -a in
'?' | '-?') ...;;
esac
BTW, for me both return "not true".
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author