From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28835 invoked by alias); 13 Feb 2015 10:49:18 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34530 Received: (qmail 20099 invoked from network); 13 Feb 2015 10:49:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,T_HDRS_LCASE,T_MANY_HDRS_LCASE autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7fc86d0000066b7-7e-54ddd6173b57 Date: Fri, 13 Feb 2015 10:48:49 +0000 From: Peter Stephenson To: Zsh Hackers' List Subject: PATCH: PRINT_EXIT_VALUE with anonymous functions, again Message-id: <20150213104849.701782fb@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphluLIzCtJLcpLzFFi42I5/e/4NV3xa3dDDF49E7M42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGXt2TWUumMRXMWmWWQPjd64uRk4OCQETicdnW1ghbDGJC/fW s3UxcnEICSxllNj18Q47hLOESeL08Z+MEM42RonzJz+wg7SwCKhKzOp6ygRiswkYSkzdNBuo iINDREBbov2jGEhYWMBB4v2nOcwgNq+AvcSVrU1g2/gF9CWu/v3EBLHZXmLmlTOMEDWCEj8m 32MBsZkFtCQ2b4OoZxaQl9i85i3YHCEBdYkbd3ezT2AUmIWkZRaSlllIWhYwMq9iFE0tTS4o TkrPNdIrTswtLs1L10vOz93ECAnBrzsYlx6zOsQowMGoxMOr2HA3RIg1say4MvcQowQHs5II 793LQCHelMTKqtSi/Pii0pzU4kOMTBycUg2MC/s/c7emWeg/Nbtrn7bF83fT4ujdrL4mHM7m 87b+jYtNWr9cle1887ff+5clv5rT7Hx20dGyA34q1zQeTJpveXTRzr7mc/L/r34uPLv1z/LD Eb+3hSil7GD8fuRHLv+v1ntRp9qPvDvyUCzLxmCisVFU3/myVUe1rhpm6kxcGSI6p36nxA0W RSWW4oxEQy3mouJEAM9II1QfAgAA Let's stick with an easy, unambiguously effective fix for this. As this is local there is no change to the simple / complex nature of the command. pws diff --git a/Src/exec.c b/Src/exec.c index 302e2b5..a60d4ff 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3359,9 +3359,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; @@ -4488,6 +4488,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 c6af803..3213534 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 ! -- Peter Stephenson | Principal Engineer Samsung Cambridge Solution Centre Email: p.stephenson@samsung.com | Phone: +44 1223 434724 | www.samsung.com