From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: Exception handling and "trap" vs. TRAPNAL()
Date: Mon, 03 Oct 2005 16:50:45 +0000 [thread overview]
Message-ID: <1051003165045.ZM5335@candle.brasslantern.com> (raw)
In-Reply-To: <5929.1128352251@csr.com>
On Oct 3, 4:10pm, Peter Stephenson wrote:
}
} 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.
Oh, goody.
} > 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.
}
} 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.
Yes, that is what I meant.
That gives us something like this (except I'm only half serious about the
emulation part):
Index: Src/loop.c
===================================================================
diff -c -r1.10 loop.c
--- Src/loop.c 18 Feb 2005 17:05:17 -0000 1.10
+++ Src/loop.c 3 Oct 2005 16:31:57 -0000
@@ -627,13 +627,17 @@
try_errflag = -1;
/**/
+zlong
+try_tryflag = 0;
+
+/**/
int
exectry(Estate state, int do_exec)
{
Wordcode end, always;
int endval;
int save_retflag, save_breaks, save_loops, save_contflag;
- zlong save_try_errflag;
+ zlong save_try_errflag, save_try_tryflag;
end = state->pc + WC_TRY_SKIP(state->pc[-1]);
always = state->pc + 1 + WC_TRY_SKIP(*state->pc);
@@ -642,7 +646,12 @@
cmdpush(CS_CURSH);
/* The :try clause */
+ save_try_tryflag = try_tryflag;
+ try_tryflag = 1;
+
execlist(state, 1, do_exec);
+
+ try_tryflag = save_try_tryflag;
/* Don't record errflag here, may be reset. */
endval = lastval;
Index: Src/signals.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/signals.c,v
retrieving revision 1.13
diff -c -r1.13 signals.c
--- Src/signals.c 28 May 2005 04:32:49 -0000 1.13
+++ Src/signals.c 3 Oct 2005 16:48:34 -0000
@@ -1003,6 +1003,7 @@
int trapret = 0;
int obreaks = breaks;
int isfunc;
+ int traperr;
/* if signal is being ignored or the trap function *
* is NULL, then return *
@@ -1097,8 +1098,8 @@
* execrestore.
*/
trapret = trapreturn + 1;
- } else if (errflag)
- trapret = 1;
+ }
+ traperr = errflag;
execrestore();
lexrestore();
@@ -1110,6 +1111,10 @@
lastval = trapret-1;
}
} else {
+ if (traperr && emulation != EMULATE_SH)
+ lastval = 1;
+ if (try_tryflag)
+ errflag = traperr;
breaks += obreaks;
if (breaks > loops)
breaks = loops;
next prev parent reply other threads:[~2005-10-03 16:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20050929200741.GA1156@DervishD>
[not found] ` <20050930124130.45eb0463.pws@csr.com>
[not found] ` <20051001153756.GA12183@DervishD>
2005-10-01 18:38 ` Bart Schaefer
2005-10-01 19:10 ` Peter Stephenson
2005-10-01 20:41 ` DervishD
2005-10-01 22:44 ` Bart Schaefer
2005-10-02 8:06 ` DervishD
2005-10-01 20:28 ` DervishD
2005-10-02 4:40 ` Bart Schaefer
2005-10-02 8:13 ` DervishD
2005-10-02 19:09 ` Peter Stephenson
2005-10-02 19:55 ` Bart Schaefer
2005-10-02 23:00 ` DervishD
2005-10-03 1:37 ` Bart Schaefer
2005-10-03 8:57 ` Peter Stephenson
2005-10-03 14:51 ` Bart Schaefer
2005-10-03 15:10 ` Peter Stephenson
2005-10-03 16:50 ` Bart Schaefer [this message]
2005-10-03 9:01 ` DervishD
2005-10-03 16:21 ` Bart Schaefer
2005-10-03 17:59 ` DervishD
2005-10-04 16:31 ` Bart Schaefer
2005-10-04 17:29 ` DervishD
2005-10-04 17:34 ` Peter Stephenson
2005-10-04 17:46 ` DervishD
2005-10-01 8:01 DervishD
-- strict thread matches above, loose matches on Subject: below --
2005-10-01 7:45 DervishD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1051003165045.ZM5335@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).