* Bug in zsh versions 4.1.1 and 4.2.0
@ 2004-07-29 14:14 Dieter Lambrecht
2004-07-29 14:56 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Dieter Lambrecht @ 2004-07-29 14:14 UTC (permalink / raw)
To: zsh-workers
Hi,
the following zsh-script running on Linux (Suse-Linux-Desktop)
#! /home/bzq090/aps4_main/aps4/test/package/zsh/zsh-4.2.0/Src/zsh
emulate -L zsh
trap 'print $LINENO' DEBUG
echo $LINENO
echo $LINENO
gives the following output:
1
6
1
7
1
Contrary to the information in "Z SHELL Manual" p. 85, LINENO is not updated correctly if used with the trap-builtin.
Kind Regards,
Dieter Lambrecht
--
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Bug in zsh versions 4.1.1 and 4.2.0
2004-07-29 14:14 Bug in zsh versions 4.1.1 and 4.2.0 Dieter Lambrecht
@ 2004-07-29 14:56 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2004-07-29 14:56 UTC (permalink / raw)
To: zsh-workers; +Cc: Dieter Lambrecht
"Dieter Lambrecht" wrote:
> Hi,
>
> the following zsh-script running on Linux (Suse-Linux-Desktop)
>
> #! /home/bzq090/aps4_main/aps4/test/package/zsh/zsh-4.2.0/Src/zsh
> emulate -L zsh
>
> trap 'print $LINENO' DEBUG
>
> echo $LINENO
> echo $LINENO
>
>
>
> gives the following output:
>
> 1
> 6
> 1
> 7
> 1
>
>
> Contrary to the information in "Z SHELL Manual" p. 85, LINENO is not
> updated correctly if used with the trap-builtin.
Yes, that's a real bug, the documentation is correct. This must have
got broken when the wordcode execution stuff came in, since I remember
sweating blood over this some years ago. It's been masked by the fact
that the buggy behaviour is encoded into the test suite; that's fixed
below as well. I'm surprised nobody noticed it before since it makes
detailed debugging a good deal harder. Maybe people now rely on PS4,
which gets the correct line number.
(I think the explanation for the test suite is that the first test,
TRAPDEBUG, is correct, also as per documentation. The example got
copied for trap '...' debug, and since it worked without alteration, no
one noticed this was wrong. The behaviour for TRAPDEBUG probably isn't
all that useful, actually; I think I decided somewhat arbitrarily
that it would respect the normal function convention. There's no prior
art in that case.)
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.68
diff -u -r1.68 exec.c
--- Src/exec.c 26 Jul 2004 13:18:14 -0000 1.68
+++ Src/exec.c 29 Jul 2004 14:48:59 -0000
@@ -787,7 +787,8 @@
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 @@
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) {
Index: Src/signals.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/signals.c,v
retrieving revision 1.29
diff -u -r1.29 signals.c
--- Src/signals.c 26 Jul 2004 13:18:14 -0000 1.29
+++ Src/signals.c 29 Jul 2004 14:49:01 -0000
@@ -943,6 +943,11 @@
/**/
int intrap;
+/* Is the current trap a function? */
+
+/**/
+int trapisfunc;
+
/**/
void
dotrapargs(int sig, int *sigtr, void *sigfn)
@@ -1001,19 +1006,19 @@
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);
Index: Test/A05execution.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A05execution.ztst,v
retrieving revision 1.3
diff -u -r1.3 A05execution.ztst
--- Test/A05execution.ztst 22 Aug 2001 15:59:27 -0000 1.3
+++ Test/A05execution.ztst 29 Jul 2004 14:49:01 -0000
@@ -136,7 +136,7 @@
rm fn
0:trap DEBUG
>Line 1
->Line 1
+>Line 2
TRAPZERR() { print Command failed; }
true
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-07-29 14:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-29 14:14 Bug in zsh versions 4.1.1 and 4.2.0 Dieter Lambrecht
2004-07-29 14:56 ` Peter Stephenson
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).