mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-28 05:00:59 +01:00
21814: error handling for traps in "always" constructs.
This commit is contained in:
parent
c3e8aec759
commit
174ad4a80f
3 changed files with 25 additions and 3 deletions
|
|
@ -1,3 +1,11 @@
|
||||||
|
2005-12-14 Bart Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 21814: Src/loop.c, Src/signals.c: if an error occurs in an
|
||||||
|
inline trap, set $? to 1, to match the behavior of pre-4.2
|
||||||
|
versions of zsh. If and only if the trap is executed within the
|
||||||
|
"try" part of an "always" construct, also propagate the error
|
||||||
|
condition so that the "try" section is aborted. (Belated commit.)
|
||||||
|
|
||||||
2005-12-14 Wayne Davison <wayned@users.sourceforge.net>
|
2005-12-14 Wayne Davison <wayned@users.sourceforge.net>
|
||||||
|
|
||||||
* 22078: Src/utils.c: made ucs4toutf8() a static function (when
|
* 22078: Src/utils.c: made ucs4toutf8() a static function (when
|
||||||
|
|
|
||||||
11
Src/loop.c
11
Src/loop.c
|
|
@ -626,6 +626,10 @@ execcase(Estate state, int do_exec)
|
||||||
zlong
|
zlong
|
||||||
try_errflag = -1;
|
try_errflag = -1;
|
||||||
|
|
||||||
|
/**/
|
||||||
|
zlong
|
||||||
|
try_tryflag = 0;
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
int
|
int
|
||||||
exectry(Estate state, int do_exec)
|
exectry(Estate state, int do_exec)
|
||||||
|
|
@ -633,7 +637,7 @@ exectry(Estate state, int do_exec)
|
||||||
Wordcode end, always;
|
Wordcode end, always;
|
||||||
int endval;
|
int endval;
|
||||||
int save_retflag, save_breaks, save_loops, save_contflag;
|
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]);
|
end = state->pc + WC_TRY_SKIP(state->pc[-1]);
|
||||||
always = state->pc + 1 + WC_TRY_SKIP(*state->pc);
|
always = state->pc + 1 + WC_TRY_SKIP(*state->pc);
|
||||||
|
|
@ -642,8 +646,13 @@ exectry(Estate state, int do_exec)
|
||||||
cmdpush(CS_CURSH);
|
cmdpush(CS_CURSH);
|
||||||
|
|
||||||
/* The :try clause */
|
/* The :try clause */
|
||||||
|
save_try_tryflag = try_tryflag;
|
||||||
|
try_tryflag = 1;
|
||||||
|
|
||||||
execlist(state, 1, do_exec);
|
execlist(state, 1, do_exec);
|
||||||
|
|
||||||
|
try_tryflag = save_try_tryflag;
|
||||||
|
|
||||||
/* Don't record errflag here, may be reset. */
|
/* Don't record errflag here, may be reset. */
|
||||||
endval = lastval;
|
endval = lastval;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1003,6 +1003,7 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
|
||||||
int trapret = 0;
|
int trapret = 0;
|
||||||
int obreaks = breaks;
|
int obreaks = breaks;
|
||||||
int isfunc;
|
int isfunc;
|
||||||
|
int traperr;
|
||||||
|
|
||||||
/* if signal is being ignored or the trap function *
|
/* if signal is being ignored or the trap function *
|
||||||
* is NULL, then return *
|
* is NULL, then return *
|
||||||
|
|
@ -1097,8 +1098,8 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
|
||||||
* execrestore.
|
* execrestore.
|
||||||
*/
|
*/
|
||||||
trapret = trapreturn + 1;
|
trapret = trapreturn + 1;
|
||||||
} else if (errflag)
|
}
|
||||||
trapret = 1;
|
traperr = errflag;
|
||||||
execrestore();
|
execrestore();
|
||||||
lexrestore();
|
lexrestore();
|
||||||
|
|
||||||
|
|
@ -1110,6 +1111,10 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
|
||||||
lastval = trapret-1;
|
lastval = trapret-1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (traperr && emulation != EMULATE_SH)
|
||||||
|
lastval = 1;
|
||||||
|
if (try_tryflag)
|
||||||
|
errflag = traperr;
|
||||||
breaks += obreaks;
|
breaks += obreaks;
|
||||||
if (breaks > loops)
|
if (breaks > loops)
|
||||||
breaks = loops;
|
breaks = loops;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue