Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Exception handling and "trap" vs. TRAPNAL()
- X-seq: zsh-workers 21812
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Exception handling and "trap" vs. TRAPNAL()
- Date: Mon, 03 Oct 2005 16:10:51 +0100
- In-reply-to: <1051003145142.ZM4427@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050929200741.GA1156@DervishD> <20050930124130.45eb0463.pws@xxxxxxx> <20051001153756.GA12183@DervishD> <1051001183818.ZM27904@xxxxxxxxxxxxxxxxxxxxxxx> <20051001202856.GA134@DervishD> <1051002044052.ZM28373@xxxxxxxxxxxxxxxxxxxxxxx> <20051002190940.437F9866F@xxxxxxxxxxxxxxxxxxxxxxxx> <1051002195518.ZM2163@xxxxxxxxxxxxxxxxxxxxxxx> <20051002230027.GA194@DervishD> <1051003013758.ZM3107@xxxxxxxxxxxxxxxxxxxxxxx> <20051003095738.3de5a059.pws@xxxxxxx> <1051003145142.ZM4427@xxxxxxxxxxxxxxxxxxxxxxx>
Bart Schaefer wrote:
> It could also be argued that, if the trap should behave like an "eval",
> it ought to set $? = 1 when an error occurs inside the trap (but still
> not cause an interrupt condition). The example of bash2 contradicts
> that position. Can anyone who is reading this try ksh?
ksh appears to set the status to 1.
> Here's a possible compromise: Use my second patch, but propagate the
> error if and only if we're in the try-block of an always-construct.
> That's guaranteed not to break old code, and continues to behave like
> bash2 in the absence of "always". Can dotrapargs() determine that it
> is in "always" context without too much trouble?
It can test try_errflag, which is usually -1 when not in an always
block and >= 0 otherwise. However that's the value of TRY_BLOCK_ERROR
which can be set by the user, so isn't actually guaranteed to be -1
outside. Either adding another flag not tied to a variable or rejecting
user attempts to set TRY_BLOCK_ERROR when it's current value is less than
zero (and therefore presumably only let it be set to such a number)
would work around this.
But do you mean how can it test if it's in the try block part? There's
no explicit test for that at the moment, but it's easy to add a variable.
pws
This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author