mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-04 22:51:42 +02:00
20221: $LINENO in trap '...' DEBUG was wrong.
This commit is contained in:
parent
efe2876d92
commit
640bbab78f
3 changed files with 13 additions and 6 deletions
|
@ -787,7 +787,8 @@ execsimple(Estate state)
|
|||
if (errflag)
|
||||
return (lastval = 1);
|
||||
|
||||
if (code)
|
||||
/* In evaluated traps, don't modify the line number. */
|
||||
if ((!intrap || trapisfunc) && code)
|
||||
lineno = code - 1;
|
||||
|
||||
code = wc_code(*state->pc++);
|
||||
|
@ -1258,7 +1259,8 @@ execpline2(Estate state, wordcode pcode,
|
|||
if (breaks || retflag)
|
||||
return;
|
||||
|
||||
if (WC_PIPE_LINENO(pcode))
|
||||
/* In evaluated traps, don't modify the line number. */
|
||||
if ((!intrap || trapisfunc) && WC_PIPE_LINENO(pcode))
|
||||
lineno = WC_PIPE_LINENO(pcode) - 1;
|
||||
|
||||
if (pline_level == 1) {
|
||||
|
|
|
@ -943,6 +943,11 @@ endtrapscope(void)
|
|||
/**/
|
||||
int intrap;
|
||||
|
||||
/* Is the current trap a function? */
|
||||
|
||||
/**/
|
||||
int trapisfunc;
|
||||
|
||||
/**/
|
||||
void
|
||||
dotrapargs(int sig, int *sigtr, void *sigfn)
|
||||
|
@ -1001,19 +1006,19 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
|
|||
zaddlinknode(args, num);
|
||||
|
||||
trapreturn = -1; /* incremented by doshfunc */
|
||||
trapisfunc = isfunc = 1;
|
||||
|
||||
sfcontext = SFC_SIGNAL;
|
||||
doshfunc(name, sigfn, args, 0, 1);
|
||||
sfcontext = osc;
|
||||
freelinklist(args, (FreeFunc) NULL);
|
||||
zsfree(name);
|
||||
|
||||
isfunc = 1;
|
||||
} else {
|
||||
trapreturn = -2; /* not incremented, used at current level */
|
||||
trapisfunc = isfunc = 0;
|
||||
|
||||
execode(sigfn, 1, 0);
|
||||
|
||||
isfunc = 0;
|
||||
}
|
||||
runhookdef(AFTERTRAPHOOK, NULL);
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
rm fn
|
||||
0:trap DEBUG
|
||||
>Line 1
|
||||
>Line 1
|
||||
>Line 2
|
||||
|
||||
TRAPZERR() { print Command failed; }
|
||||
true
|
||||
|
|
Loading…
Reference in a new issue