mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 13:01:28 +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)
|
if (errflag)
|
||||||
return (lastval = 1);
|
return (lastval = 1);
|
||||||
|
|
||||||
if (code)
|
/* In evaluated traps, don't modify the line number. */
|
||||||
|
if ((!intrap || trapisfunc) && code)
|
||||||
lineno = code - 1;
|
lineno = code - 1;
|
||||||
|
|
||||||
code = wc_code(*state->pc++);
|
code = wc_code(*state->pc++);
|
||||||
|
@ -1258,7 +1259,8 @@ execpline2(Estate state, wordcode pcode,
|
||||||
if (breaks || retflag)
|
if (breaks || retflag)
|
||||||
return;
|
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;
|
lineno = WC_PIPE_LINENO(pcode) - 1;
|
||||||
|
|
||||||
if (pline_level == 1) {
|
if (pline_level == 1) {
|
||||||
|
|
|
@ -943,6 +943,11 @@ endtrapscope(void)
|
||||||
/**/
|
/**/
|
||||||
int intrap;
|
int intrap;
|
||||||
|
|
||||||
|
/* Is the current trap a function? */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
int trapisfunc;
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
void
|
void
|
||||||
dotrapargs(int sig, int *sigtr, void *sigfn)
|
dotrapargs(int sig, int *sigtr, void *sigfn)
|
||||||
|
@ -1001,19 +1006,19 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
|
||||||
zaddlinknode(args, num);
|
zaddlinknode(args, num);
|
||||||
|
|
||||||
trapreturn = -1; /* incremented by doshfunc */
|
trapreturn = -1; /* incremented by doshfunc */
|
||||||
|
trapisfunc = isfunc = 1;
|
||||||
|
|
||||||
sfcontext = SFC_SIGNAL;
|
sfcontext = SFC_SIGNAL;
|
||||||
doshfunc(name, sigfn, args, 0, 1);
|
doshfunc(name, sigfn, args, 0, 1);
|
||||||
sfcontext = osc;
|
sfcontext = osc;
|
||||||
freelinklist(args, (FreeFunc) NULL);
|
freelinklist(args, (FreeFunc) NULL);
|
||||||
zsfree(name);
|
zsfree(name);
|
||||||
|
|
||||||
isfunc = 1;
|
|
||||||
} else {
|
} else {
|
||||||
trapreturn = -2; /* not incremented, used at current level */
|
trapreturn = -2; /* not incremented, used at current level */
|
||||||
|
trapisfunc = isfunc = 0;
|
||||||
|
|
||||||
execode(sigfn, 1, 0);
|
execode(sigfn, 1, 0);
|
||||||
|
|
||||||
isfunc = 0;
|
|
||||||
}
|
}
|
||||||
runhookdef(AFTERTRAPHOOK, NULL);
|
runhookdef(AFTERTRAPHOOK, NULL);
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
rm fn
|
rm fn
|
||||||
0:trap DEBUG
|
0:trap DEBUG
|
||||||
>Line 1
|
>Line 1
|
||||||
>Line 1
|
>Line 2
|
||||||
|
|
||||||
TRAPZERR() { print Command failed; }
|
TRAPZERR() { print Command failed; }
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in a new issue