about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-11-03 13:57:52 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-11-03 13:57:52 +0000
commita7b9b5f851898c569b4887afcdf768c3d5b058df (patch)
tree28f0b74a7e8f96c96903887e3a5af5303bbfd2b5 /Src
parentd90e97e16a7f9343fbec9d9b33da45806b2a4e89 (diff)
downloadzsh-a7b9b5f851898c569b4887afcdf768c3d5b058df.tar.gz
zsh-a7b9b5f851898c569b4887afcdf768c3d5b058df.tar.xz
zsh-a7b9b5f851898c569b4887afcdf768c3d5b058df.zip
19218: extend 19216 to zle widgets
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_main.c6
-rw-r--r--Src/exec.c20
2 files changed, 16 insertions, 10 deletions
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 7309e3763..15423d231 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -910,7 +910,7 @@ execzlefunc(Thingy func, char **args)
 	    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 @@ execzlefunc(Thingy func, char **args)
 	    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;
diff --git a/Src/exec.c b/Src/exec.c
index 5b17371bb..2d9f7ed26 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3436,17 +3436,22 @@ loadautofn(Shfunc shf, int fksh, int autol)
     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 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
 
     if (trapreturn < -1)
 	trapreturn++;
+    ret = lastval;
     if (noreturnval) {
 	lastval = oldlastval;
 	numpipestats = oldnumpipestats;
@@ -3599,6 +3605,8 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval)
 	    zexit(exit_pending >> 1, 0);
 	}
     }
+
+    return ret;
 }
 
 /* This finally executes a shell function and any function wrappers     *