From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29812 invoked by alias); 12 Feb 2015 05:30:59 -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: 34514 Received: (qmail 20901 invoked from network); 12 Feb 2015 05:30:58 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=I4zSn2kl c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=0HtSIViG9nkA:10 a=T2-4gqiCUloAEfYuxAIA:9 a=bLbRVBEicQSf-lju:21 a=4J_ihefdfgmNbhws:21 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150211213054.ZM19450@torch.brasslantern.com> Date: Wed, 11 Feb 2015 21:30:54 -0800 In-reply-to: <54DC34EF.4010204@eastlink.ca> Comments: In reply to Ray Andrews "Re: completion problem with '291' ok with '274'." (Feb 11, 9:06pm) References: <54DA87F5.5090303@eastlink.ca> <150210183520.ZM16470@torch.brasslantern.com> <54DACEF7.90605@eastlink.ca> <150210202035.ZM16595@torch.brasslantern.com> <54DAF251.4040702@eastlink.ca> <150211082827.ZM17558@torch.brasslantern.com> <54DB93F2.6090202@eastlink.ca> <54DBE5BF.3020609@eastlink.ca> <54DC0675.4040808@eastlink.ca> <54DC34EF.4010204@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: completion problem with '291' ok with '274'. MIME-version: 1.0 Content-type: text/plain; charset=us-ascii n Feb 11, 8:00pm, Bart Schaefer wrote: } } I'm not sure about the exec.c change that moved the "if (do_exec)" block, } but I'm wondering whether it has to do with Ray's mysterious shell exits, } because it makes an _exit() call. And sure enough ... On Feb 11, 9:06pm, Ray Andrews wrote: } Subject: Re: completion problem with '291' ok with '274'. } } Breakpoint 2, _exit () at ../sysdeps/unix/sysv/linux/i386/_exit.S:24 } 24 ../sysdeps/unix/sysv/linux/i386/_exit.S: No such file or directory. } (gdb) where } #0 _exit () at ../sysdeps/unix/sysv/linux/i386/_exit.S:24 } #1 0xb7dda0e7 in __run_exit_handlers (status=status@entry=0, } listp=0xb7f503c4 <__exit_funcs>, } run_list_atexit=run_list_atexit@entry=true) at exit.c:97 } #2 0xb7dda17d in __GI_exit (status=0) at exit.c:104 } #3 0x080667a3 in execcmd (state=0xbfffa8a0, input=0, output=0, how=18, } last1=1) at exec.c:3494 So basically we have to back out all of 34485 and start that over. Here's the reverse diff for 34485: diff --git a/Src/exec.c b/Src/exec.c index 9bbcf49..3b0e936 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2427,7 +2427,6 @@ execcmd(Estate state, int input, int output, int how, int last1) wordcode code; Wordcode beg = state->pc, varspc; FILE *oxtrerr = xtrerr, *newxtrerr = NULL; - LinkList restorelist = 0, removelist = 0; doneps4 = 0; redir = (wc_code(*state->pc) == WC_REDIR ? ecgetredirs(state) : NULL); @@ -3360,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; @@ -3375,6 +3374,7 @@ execcmd(Estate state, int input, int output, int how, int last1) } else lastval = (execfuncs[type - WC_CURSH])(state, do_exec); } else if (is_builtin || is_shfunc) { + LinkList restorelist = 0, removelist = 0; /* builtin or shell function */ if (!forked && ((cflags & BINF_COMMAND) || @@ -3424,6 +3424,29 @@ execcmd(Estate state, int input, int output, int how, int last1) } else clearerr(stdout); } + if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) && + lastval && !subsh) { +#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); + } + + if (do_exec) { + if (subsh) + _exit(lastval); + + /* If we are exec'ing a command, and we are not in a subshell, * + * then check if we should save the history file. */ + if (isset(RCS) && interact && !nohistsave) + savehistfile(NULL, 1, HFILE_USE_OPTIONS); + exit(lastval); + } + if (restorelist) + restore_params(restorelist, removelist); + } else { if (!forked) setiparam("SHLVL", --shlvl); @@ -3473,28 +3496,6 @@ execcmd(Estate state, int input, int output, int how, int last1) execlist(state, 0, 1); } } - if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) && - lastval && !subsh) { -#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); - } - - if (do_exec) { - if (subsh) - _exit(lastval); - - /* If we are exec'ing a command, and we are not in a subshell, * - * then check if we should save the history file. */ - if (isset(RCS) && interact && !nohistsave) - savehistfile(NULL, 1, HFILE_USE_OPTIONS); - exit(lastval); - } - if (restorelist) - restore_params(restorelist, removelist); } err: diff --git a/Src/parse.c b/Src/parse.c index ffd25de..0b54a90 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -1612,7 +1612,8 @@ par_funcdef(int *cmplx) num++; zshlex(); } - *cmplx = 1; + if (num > 0) + *cmplx = 1; ecbuf[parg] = ecused - parg; /*?*/ ecbuf[parg+1] = num; } @@ -1896,7 +1897,8 @@ par_simple(int *cmplx, int nr) argc++; zshlex(); } - *cmplx = 1; + if (argc > 0) + *cmplx = 1; ecbuf[parg] = ecused - parg; /*?*/ ecbuf[parg+1] = argc; } diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 3213534..46b1837 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -783,24 +783,14 @@ >print is a shell builtin ?(eval):8: command not found: print -# PRINTEXITVALUE only works if shell input is coming from standard input. -# Goodness only knows why. - $ZTST_testdir/../Src/zsh -f <<<' - setopt printexitvalue - func() { - false - } - func - ' -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 +# This option seems to be problematic. I don't quite know how it works. +## func() { +## setopt localoptions printexitvalue +## false +## } +## func +## 1:PRINT_EXIT_VALUE option +## ?(eval):2: exit 1 setopt promptbang print -P !