summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/exec.c14
-rw-r--r--Test/E01options.ztst12
3 files changed, 23 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index c389b936d..6fb13715a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,11 @@
* 34546: Src/exec.c, Test/D04parameter.ztst: fix another
oddity with $_ and anonymous functions and add tests.
+2015-02-13 Peter Stephenson <p.stephenson@samsung.com>
+
+ * 34530: Src/exec.c, Test/E01options.ztst: revised fix
+ for PRINT_EXIT_VALUE from anonymous functions.
+
2015-02-12 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 34519: Src/exec.c: handle $_ with arguments to anonymous
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);
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index c6af80392..32135344f 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -795,12 +795,12 @@
1:PRINT_EXIT_VALUE option
?zsh: exit 1
-# $ZTST_testdir/../Src/zsh -f <<<'
-# setopt printexitvalue
-# () { false; }
-# '
-#1:PRINT_EXIT_VALUE option for anonymous function
-#?zsh: exit 1
+ $ZTST_testdir/../Src/zsh -f <<<'
+ setopt printexitvalue
+ () { false; }
+ '
+1:PRINT_EXIT_VALUE option for anonymous function
+?zsh: exit 1
setopt promptbang
print -P !