From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16073 invoked from network); 3 Nov 2003 13:05:00 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 3 Nov 2003 13:05:00 -0000 Received: (qmail 12726 invoked by alias); 3 Nov 2003 13:04:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19218 Received: (qmail 12703 invoked from network); 3 Nov 2003 13:04:50 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 3 Nov 2003 13:04:50 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.183.235] by sunsite.dk (MessageWall 1.0.8) with SMTP; 3 Nov 2003 13:4:50 -0000 Received: from EXCHANGE02.csr.com (unverified) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.10) with ESMTP id for ; Mon, 3 Nov 2003 13:04:54 +0000 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.5329); Mon, 3 Nov 2003 13:05:45 +0000 To: Zsh workers Subject: Re: $pipestatus broken In-reply-to: "Oliver Kiddle"'s message of "Mon, 03 Nov 2003 13:56:28 +0100." <15861.1067864188@gmcs3.local> Date: Mon, 03 Nov 2003 13:04:48 +0000 Message-ID: <9516.1067864688@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 03 Nov 2003 13:05:45.0959 (UTC) FILETIME=[31C12F70:01C3A20B] Oliver Kiddle wrote: > As it happens, I don't have a precmd function defined. Peter's patch > didn't help: it seems the problem for my setup is down to zle widgets. In > particular, I have one defined for the enter key as a wrapper around > accept-line. $status seems unaffected so it looks like we need to be > saving pipestats somewhere else too. Is this any good? I haven't properly tested it since you're more in a position to see if it fixes things. The widget code wasn't using the save-return-values facilities of doshfunc because it wanted the status. I've made doshfunc pass that back separately. Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.55 diff -u -r1.55 exec.c --- Src/exec.c 3 Nov 2003 11:33:46 -0000 1.55 +++ Src/exec.c 3 Nov 2003 13:01:25 -0000 @@ -3436,17 +3436,22 @@ return shf; } -/* execute a shell function */ +/* + * execute a shell function + * + * If noreturnval is nonzero, then reset the current return + * value (lastval) to its value before the shell function + * was executed. However, in any case return the status value + * from the function (i.e. if noreturnval is not set, this + * will be the same as lastval). + */ /**/ -mod_export void +mod_export int doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) -/* If noreturnval is nonzero, then reset the current return * - * value (lastval) to its value before the shell function * - * was executed. */ { char **tab, **x, *oargv0; - int oldzoptind, oldlastval, oldoptcind, oldnumpipestats; + int oldzoptind, oldlastval, oldoptcind, oldnumpipestats, ret; int *oldpipestats = NULL; char saveopts[OPT_SIZE], *oldscriptname = scriptname, *fname = dupstring(name); int obreaks; @@ -3577,6 +3582,7 @@ if (trapreturn < -1) trapreturn++; + ret = lastval; if (noreturnval) { lastval = oldlastval; numpipestats = oldnumpipestats; @@ -3599,6 +3605,8 @@ zexit(exit_pending >> 1, 0); } } + + return ret; } /* This finally executes a shell function and any function wrappers * Index: Src/Zle/zle_main.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v retrieving revision 1.36 diff -u -r1.36 zle_main.c --- Src/Zle/zle_main.c 29 Oct 2003 19:17:48 -0000 1.36 +++ Src/Zle/zle_main.c 3 Nov 2003 13:01:25 -0000 @@ -910,7 +910,7 @@ zsfree(msg); ret = 1; } else { - int osc = sfcontext, osi = movefd(0), olv = lastval; + int osc = sfcontext, osi = movefd(0); int oxt = isset(XTRACE); LinkList largs = NULL; @@ -924,10 +924,8 @@ makezleparams(0); sfcontext = SFC_WIDGET; opts[XTRACE] = 0; - doshfunc(w->u.fnnam, prog, largs, shf->flags, 0); + ret = doshfunc(w->u.fnnam, prog, largs, shf->flags, 1); opts[XTRACE] = oxt; - ret = lastval; - lastval = olv; sfcontext = osc; endparamscope(); lastcmd = 0; -- Peter Stephenson 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 **********************************************************************