summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-02-16 12:37:38 +0000
committerPeter Stephenson <pws@zsh.org>2015-02-16 12:37:38 +0000
commit8ebe18c081a0bd2f134f5fcbf1650d5d59920c96 (patch)
treead956694f15df0fcfe91c1c0d197664b7ae45ff0 /Src/exec.c
parent2335d6254815050d3a0ae9b5a8677ec2f567b631 (diff)
downloadzsh-8ebe18c081a0bd2f134f5fcbf1650d5d59920c96.tar.gz
zsh-8ebe18c081a0bd2f134f5fcbf1650d5d59920c96.tar.xz
zsh-8ebe18c081a0bd2f134f5fcbf1650d5d59920c96.zip
34530: PRINT_EXIT_VALUE with anonymous functions.
Simpler fix, avoiding structural changes.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c
index de6b9c574..947b815f9 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3364,9 +3364,9 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		zcontext_restore();
 	    } else
 		redir_prog = NULL;
-	    
+
 	    lastval = execfuncdef(state, redir_prog);
-	} 
+	}
 	else if (type >= WC_CURSH) {
 	    if (last1 == 1)
 		do_exec = 1;
@@ -4495,6 +4495,16 @@ execfuncdef(Estate state, Eprog redir_prog)
 	    execshfunc(shf, args);
 	    ret = lastval;
 
+	    if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
+		lastval) {
+#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
+		fprintf(stderr, "zsh: exit %lld\n", lastval);
+#else
+		fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
+#endif
+		fflush(stderr);
+	    }
+
 	    freeeprog(shf->funcdef);
 	    if (shf->redir) /* shouldn't be */
 		freeeprog(shf->redir);