Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: exit status
- X-seq: zsh-workers 22995
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: Re: PATCH: exit status
- Date: Fri, 10 Nov 2006 16:09:10 +0000
- In-reply-to: <061110075808.ZM4615@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <200611100940.kAA9ewZY012583@xxxxxxxxxxxxxx> <061110075808.ZM4615@xxxxxxxxxxxxxxxxxxxxxx>
Bart Schaefer wrote:
> On Nov 10, 9:40am, Peter Stephenson wrote:
> }
> } A thread on the Austin group suggests the exit status of the shell
> } should be available in exit traps.
>
> I'm leaning towards Don Cragun's camp (the prior-to-this-patch zsh
> behavior) on this one.
I can see arguments for both sides; it turns whether you consider the
"exit" command itself to have been executed before the exit traps run,
which is a bit Zen-like. What finally convinced me is that knowing the
exit status in $? is potentially useful; knowing the status of whatever
command happened to run before is very unlikely to be. In other
words, if we *do* leave it the old way it simply means the status isn't
useful.
> I think the answer (and a general issue about
> the new hook functions, incidentally) is tied to the answer to this
> other question:
>
> What is the final exit status of the shell when the exit trap itself
> calls exit?
>
> If
> trap 'exit 42' EXIT; exit 1
>
> returns 42 to the calling environment, then Korn and the GNU guys are
> correct. If it exits 1, then Don Cragun is correct.
>
> Similarly, what happens if the zshexit hook calls exit? What happens
> if the zshexit hook calls "return 37"?
I alluded to this briefly: hooks and traps run in special contexts which
don't alter the global status. This has been the case for some time
(though I don't think it was originally like that---early versions were
fairly wayward about return statuses). That's required in some specific
cases --- the DEBUG trap would be unusable (or at least need extreme
care in writing) if its status were returned to the main shell. Also,
if we have multiple exit hooks and want them to get the same status
(since they shouldn't care about previous hooks) we need their return
statuses to be protected. That's how it currently works.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
Messages sorted by:
Reverse Date,
Date,
Thread,
Author