zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Zsh workers <zsh-workers@sunsite.dk>
Subject: Re: $pipestatus broken
Date: Mon, 03 Nov 2003 13:04:48 +0000	[thread overview]
Message-ID: <9516.1067864688@csr.com> (raw)
In-Reply-To: "Oliver Kiddle"'s message of "Mon, 03 Nov 2003 13:56:28 +0100." <15861.1067864188@gmcs3.local>

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 <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
**********************************************************************


  reply	other threads:[~2003-11-03 13:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-02 11:23 Oliver Kiddle
2003-11-03  1:55 ` Bart Schaefer
2003-11-03 11:24   ` Peter Stephenson
2003-11-03 12:56   ` Oliver Kiddle
2003-11-03 13:04     ` Peter Stephenson [this message]
2003-11-03 13:35       ` Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9516.1067864688@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).