* trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS
@ 2008-08-04 10:08 Rocky Bernstein
2008-08-04 17:49 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Rocky Bernstein @ 2008-08-04 10:08 UTC (permalink / raw)
To: zsh-workers
The following code doesn't show $? as nonzero inside trap DEBUG using the
CVS source I just downloaded and built.
However I don't get this problem on the Ubuntu zsh-beta or zsh.
Removing DEBUG_BEFORE_CMD (or I guess having debug run after the
command) does set/show $? properly.
#!/tmp/zsh/Src/zsh -f
#!/src/external-cvs/zsh/Src/zsh -f
set -o DEBUG_BEFORE_CMD
trap 'print $?' DEBUG
fdasfsdafd # invalid command
:
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS
2008-08-04 10:08 trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS Rocky Bernstein
@ 2008-08-04 17:49 ` Peter Stephenson
2008-08-05 8:33 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2008-08-04 17:49 UTC (permalink / raw)
To: zsh-workers
On Mon, 4 Aug 2008 06:08:39 -0400
"Rocky Bernstein" <rocky.bernstein@gmail.com> wrote:
> The following code doesn't show $? as nonzero inside trap DEBUG using the
> CVS source I just downloaded and built.
>
> However I don't get this problem on the Ubuntu zsh-beta or zsh.
> Removing DEBUG_BEFORE_CMD (or I guess having debug run after the
> command) does set/show $? properly.
>
> #!/tmp/zsh/Src/zsh -f
> #!/src/external-cvs/zsh/Src/zsh -f
> set -o DEBUG_BEFORE_CMD
> trap 'print $?' DEBUG
> fdasfsdafd # invalid command
> :
Turns out to be unfinished business with the previous patch: that code I
patched needs also to be told when we're not in a trap at all. It was
triggering after the trap, resetting the status.
I must write tests for both.
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.89
diff -u -r1.89 init.c
--- Src/init.c 4 Aug 2008 17:32:20 -0000 1.89
+++ Src/init.c 4 Aug 2008 17:46:26 -0000
@@ -191,7 +191,7 @@
exit(lastval);
if (((!interact || sourcelevel) && errflag) || retflag)
break;
- if (trapreturn >= 0) {
+ if (intrap && trapreturn >= 0) {
lastval = trapreturn;
trapreturn = 0;
}
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS
2008-08-04 17:49 ` Peter Stephenson
@ 2008-08-05 8:33 ` Peter Stephenson
2008-08-05 23:25 ` Rocky Bernstein
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2008-08-05 8:33 UTC (permalink / raw)
To: zsh-workers
Here's a test for the first bug.
I didn't find one for the second: it's tied to reading commands line by
line from the top-level loop and even running it as a script didn't trigger
it for some reason.
Index: Test/C03traps.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C03traps.ztst,v
retrieving revision 1.11
diff -u -r1.11 C03traps.ztst
--- Test/C03traps.ztst 29 May 2007 14:50:29 -0000 1.11
+++ Test/C03traps.ztst 5 Aug 2008 08:32:02 -0000
@@ -350,6 +350,44 @@
>trap
>Working 0
+ debug-trap-bug1() {
+ setopt localtraps
+ print "print bug file here" >bug-file
+ print "print this is line one
+ print this is line two
+ print this is line three
+ print and this is line fifty-nine." >bug-file2
+ function debug_trap_handler {
+ print $functrace[1]
+ do_bug
+ }
+ function do_bug {
+ . ./bug-file
+ }
+ trap 'echo EXIT hit' EXIT
+ trap 'debug_trap_handler' DEBUG
+ . ./bug-file2
+ }
+ debug-trap-bug1
+0: Relationship between traps and sources
+>debug-trap-bug1:15
+>bug file here
+>this is line one
+>./bug-file2:1
+>bug file here
+>this is line two
+>./bug-file2:2
+>bug file here
+>this is line three
+>./bug-file2:3
+>bug file here
+>and this is line fifty-nine.
+>./bug-file2:4
+>bug file here
+>debug-trap-bug1:16
+>bug file here
+>EXIT hit
+
%clean
rm -f TRAPEXIT
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS
2008-08-05 8:33 ` Peter Stephenson
@ 2008-08-05 23:25 ` Rocky Bernstein
2008-08-06 8:49 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Rocky Bernstein @ 2008-08-05 23:25 UTC (permalink / raw)
To: zsh-workers
I didn't have a problem writing a program that when run gives exit
code 0 if this bug is fixed and exit code 10 if not.
I tried from checked out sources from a couple days ago when there was
a bug versus currently patched sources. It probably shouldn't be too
hard to work this into the testing system.
#!/usr/local/bin/zsh -f
cmd='./fdasfsdafd'
[[ -x $cmd ]] && rm $cmd
set -o DEBUG_BEFORE_CMD
trap '[[ $? -ne 0 ]] && exit 0' DEBUG
$cmd # invalid command
# Failure
exit 10
# Put the above in a file, call it and test the exit code.
On Tue, Aug 5, 2008 at 4:33 AM, Peter Stephenson <pws@csr.com> wrote:
> Here's a test for the first bug.
>
> I didn't find one for the second: it's tied to reading commands line by
> line from the top-level loop and even running it as a script didn't trigger
> it for some reason.
>
> Index: Test/C03traps.ztst
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Test/C03traps.ztst,v
> retrieving revision 1.11
> diff -u -r1.11 C03traps.ztst
> --- Test/C03traps.ztst 29 May 2007 14:50:29 -0000 1.11
> +++ Test/C03traps.ztst 5 Aug 2008 08:32:02 -0000
> @@ -350,6 +350,44 @@
> >trap
> >Working 0
>
> + debug-trap-bug1() {
> + setopt localtraps
> + print "print bug file here" >bug-file
> + print "print this is line one
> + print this is line two
> + print this is line three
> + print and this is line fifty-nine." >bug-file2
> + function debug_trap_handler {
> + print $functrace[1]
> + do_bug
> + }
> + function do_bug {
> + . ./bug-file
> + }
> + trap 'echo EXIT hit' EXIT
> + trap 'debug_trap_handler' DEBUG
> + . ./bug-file2
> + }
> + debug-trap-bug1
> +0: Relationship between traps and sources
> +>debug-trap-bug1:15
> +>bug file here
> +>this is line one
> +>./bug-file2:1
> +>bug file here
> +>this is line two
> +>./bug-file2:2
> +>bug file here
> +>this is line three
> +>./bug-file2:3
> +>bug file here
> +>and this is line fifty-nine.
> +>./bug-file2:4
> +>bug file here
> +>debug-trap-bug1:16
> +>bug file here
> +>EXIT hit
> +
> %clean
>
> rm -f TRAPEXIT
>
>
> --
> Peter Stephenson <pws@csr.com> Software Engineer
> CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
> Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS
2008-08-05 23:25 ` Rocky Bernstein
@ 2008-08-06 8:49 ` Peter Stephenson
0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2008-08-06 8:49 UTC (permalink / raw)
To: zsh-workers
On Tue, 5 Aug 2008 19:25:58 -0400
"Rocky Bernstein" <rocky.bernstein@gmail.com> wrote:
> I didn't have a problem writing a program that when run gives exit
> code 0 if this bug is fixed and exit code 10 if not.
>
> I tried from checked out sources from a couple days ago when there was
> a bug versus currently patched sources. It probably shouldn't be too
> hard to work this into the testing system.
I'll put it in as is. I think I may have confused myself over the fact
that I head the shell in two states: before fixing the first bug, and after
fixing the second bug, and this condition didn't turn up. It's worth
testing for.
The previous test depends on DEBUG_BEFORE_CMD not being set.
Index: Test/C03traps.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C03traps.ztst,v
retrieving revision 1.12
diff -u -r1.12 C03traps.ztst
--- Test/C03traps.ztst 5 Aug 2008 08:41:24 -0000 1.12
+++ Test/C03traps.ztst 6 Aug 2008 08:48:04 -0000
@@ -350,6 +350,7 @@
>trap
>Working 0
+ unsetopt DEBUG_BEFORE_CMD
debug-trap-bug1() {
setopt localtraps
print "print bug file here" >bug-file
@@ -388,6 +389,19 @@
>bug file here
>EXIT hit
+ cat >zsh-trapreturn-bug2 <<-'HERE'
+ cmd='./fdasfsdafd'
+ [[ -x $cmd ]] && rm $cmd
+ set -o DEBUG_BEFORE_CMD
+ trap '[[ $? -ne 0 ]] && exit 0' DEBUG
+ $cmd # invalid command
+ # Failure
+ exit 10
+ HERE
+ $ZTST_testdir/../Src/zsh -f ./zsh-trapreturn-bug2
+0: trapreturn handling bug is properly fixed
+?./zsh-trapreturn-bug2:5: no such file or directory: ./fdasfsdafd
+
%clean
rm -f TRAPEXIT
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-08-06 8:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-04 10:08 trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS Rocky Bernstein
2008-08-04 17:49 ` Peter Stephenson
2008-08-05 8:33 ` Peter Stephenson
2008-08-05 23:25 ` Rocky Bernstein
2008-08-06 8:49 ` 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).