Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: minor condition fixes
Peter Stephenson wrote:
> On Fri, 19 Feb 2010 12:02:37 +0000
> Peter Stephenson <pws@xxxxxxx> wrote:
> > Then there's a problem I haven't fixed, which is for some reason in the
> > test code the status is returning as 1 for an unrecognised condition
> > whereas it should return 2 (and does at the command line). This shows
> > up with:
> >
> > % eval '[[ -fail badly ]]'
> > zsh: unknown condition: -fail
> > % print $?
> > 1
>
> I think it's as simple as the following; certainly the documentation for
> "eval" says quite clearly it returns the same status as executing the code
> directly, and so does the principle of least surprise, so I don't see how
> the current behaviour can be right.
Interestingly, bash also returns status 1 on an unrecognised condition
when it's in an eval (else status 258). I checked the standard, and
it seems to agree with the zsh documentation (what I think I've now
implemented):
If there are no arguments, or only null arguments, eval shall return a
zero exit status; otherwise, it shall return the exit status of the
command defined by the string of concatenated arguments separated by
<space> characters.
with no exception for errors. The only mention of errors is
CONSEQUENCES OF ERRORS
Default.
which I think simply refers to whether or not the shell exits.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author