From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14384 invoked from network); 1 Oct 2008 11:32:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 1 Oct 2008 11:32:22 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 82825 invoked from network); 1 Oct 2008 11:32:14 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Oct 2008 11:32:14 -0000 Received: (qmail 28741 invoked by alias); 1 Oct 2008 11:31:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25791 Received: (qmail 28718 invoked from network); 1 Oct 2008 11:31:55 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 1 Oct 2008 11:31:55 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 4C61B8030847 for ; Wed, 1 Oct 2008 13:31:48 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly11d.srv.mailcontrol.com (MailControl) with ESMTP id m91BVgvs010320 for ; Wed, 1 Oct 2008 12:31:47 +0100 Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Wed, 1 Oct 2008 12:31:07 +0100 Date: Wed, 1 Oct 2008 12:31:07 +0100 From: Peter Stephenson To: "Zsh hackers list" Subject: Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection) Message-ID: <20081001123107.1113468f@news01> In-Reply-To: <6cd6de210809301059o64216c18wfb69491c5ff7b049@mail.gmail.com> References: <6cd6de210809281219i4bf1ed18mefa45b967fa835a6@mail.gmail.com> <6cd6de210809281932u2e04a844l219d1db5a7568a73@mail.gmail.com> <20080929095201.451381d0@news01> <6cd6de210809290411m60cb669bk3817d768adce378a@mail.gmail.com> <200809291125.m8TBPsQM005256@news01.csr.com> <6cd6de210809290711j12363e1bo159e1739bae7b2fd@mail.gmail.com> <200809291425.m8TEPSoR007204@news01.csr.com> <20080929224209.1bd8f3f6@pws-pc> <6cd6de210809291718n2fa49590q42eaec499d106284@mail.gmail.com> <20080930175300.2e93fabf@news01> <6cd6de210809301059o64216c18wfb69491c5ff7b049@mail.gmail.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 01 Oct 2008 11:31:07.0739 (UTC) FILETIME=[325912B0:01C923B9] X-Scanned-By: MailControl A-08-50-15 (www.mailcontrol.com) on 10.68.0.121 X-Virus-Scanned: ClamAV 0.92.1/8366/Wed Oct 1 12:44:34 2008 on bifrost X-Virus-Status: Clean On Tue, 30 Sep 2008 13:59:43 -0400 "Rocky Bernstein" 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 Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070