Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- X-seq: zsh-workers 25791
- From: Peter Stephenson <pws@xxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Date: Wed, 1 Oct 2008 12:31:07 +0100
- In-reply-to: <6cd6de210809301059o64216c18wfb69491c5ff7b049@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: CSR
- References: <6cd6de210809281219i4bf1ed18mefa45b967fa835a6@xxxxxxxxxxxxxx> <6cd6de210809281932u2e04a844l219d1db5a7568a73@xxxxxxxxxxxxxx> <20080929095201.451381d0@news01> <6cd6de210809290411m60cb669bk3817d768adce378a@xxxxxxxxxxxxxx> <200809291125.m8TBPsQM005256@xxxxxxxxxxxxxx> <6cd6de210809290711j12363e1bo159e1739bae7b2fd@xxxxxxxxxxxxxx> <200809291425.m8TEPSoR007204@xxxxxxxxxxxxxx> <20080929224209.1bd8f3f6@pws-pc> <6cd6de210809291718n2fa49590q42eaec499d106284@xxxxxxxxxxxxxx> <20080930175300.2e93fabf@news01> <6cd6de210809301059o64216c18wfb69491c5ff7b049@xxxxxxxxxxxxxx>
On Tue, 30 Sep 2008 13:59:43 -0400
"Rocky Bernstein" <rocky.bernstein@xxxxxxxxx> wrote:
> My mistake. You are correct. This bug was introduced in paring down
> the program and removing an initial truncate output (leaving the
> subsequent append outputs). And I now see the answer to why output was
> disappearing in the subshell which was my initial concern.
OK, so it seems there's currently nothing for me to look at here.
> Any thoughts on marking subshell level inside one of the stack traces
> or having return inside trap DEBUG with a negative number cause an
> immediate return?
You can already force a return from the enclosing function from trap '...'
DEBUG just by executing "return". You can use return from within enclosing
functions to trigger this, e.g.
fn() {
return 3
}
trap 'fn || return $?' DEBUG
(if you need to return status 0, offset the status return value from fn by
1 and use 'fn || return $(( $? - 1 ))'). For example
foo() {
emulate -L zsh
trap '[[ $ZSH_DEBUG_CMD == *bar* ]] && return 1' DEBUG
echo foo
echo bar
}
when executed (with DEBUG_BEFORE_CMD assumed set by default) prints "foo"
but not "bar" and should return status 1 from foo. However --- Surprise!
--- there's a bug and although it does return from foo the status gets
lost. The fix is below.
Let us know either if this isn't working properly or you need something
more specific.
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.158
diff -u -r1.158 exec.c
--- Src/exec.c 29 Sep 2008 21:46:58 -0000 1.158
+++ Src/exec.c 1 Oct 2008 11:24:43 -0000
@@ -1091,7 +1091,8 @@
exiting = donetrap;
ret = lastval;
dotrap(SIGDEBUG);
- lastval = ret;
+ if (!retflag)
+ lastval = ret;
donetrap = exiting;
noerrexit = oldnoerrexit;
/*
@@ -1230,7 +1231,8 @@
exiting = donetrap;
ret = lastval;
dotrap(SIGDEBUG);
- lastval = ret;
+ if (!retflag)
+ lastval = ret;
donetrap = exiting;
noerrexit = oldnoerrexit;
opts[ERREXIT] = oerrexit_opt;
Index: Test/C05debug.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C05debug.ztst,v
retrieving revision 1.2
diff -u -r1.2 C05debug.ztst
--- Test/C05debug.ztst 5 Sep 2008 09:05:23 -0000 1.2
+++ Test/C05debug.ztst 1 Oct 2008 11:24:43 -0000
@@ -137,3 +137,13 @@
>9: 'fn2'
>0: 'echo wow'
>wow
+
+ foo() {
+ emulate -L zsh; setopt debugbeforecmd
+ trap '[[ $ZSH_DEBUG_CMD == *bar* ]] && return 2' DEBUG
+ echo foo
+ echo bar
+ }
+ foo
+2:Status of forced return from eval-style DEBUG trap
+>foo
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
- References:
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author