zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: completion problem with '291' ok with '274'.
Date: Wed, 11 Feb 2015 21:30:54 -0800	[thread overview]
Message-ID: <150211213054.ZM19450@torch.brasslantern.com> (raw)
In-Reply-To: <54DC34EF.4010204@eastlink.ca>

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 !


  parent reply	other threads:[~2015-02-12  5:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 22:36 Ray Andrews
2015-02-11  2:35 ` Bart Schaefer
2015-02-11  3:39   ` Ray Andrews
2015-02-11  4:20     ` Bart Schaefer
2015-02-11  6:10       ` Ray Andrews
2015-02-11 16:28         ` Bart Schaefer
2015-02-11 17:40           ` Ray Andrews
2015-02-11 20:54             ` Bart Schaefer
2015-02-11 23:29               ` Ray Andrews
     [not found]                 ` <CAH+w=7Yx5FX4ZOB=EKbNULy86+Q+czDM-YA90-j3H=X4v2eS0w@mail.gmail.com>
     [not found]                   ` <54DC0675.4040808@eastlink.ca>
     [not found]                     ` <CAH+w=7YisQBt_UJLjv4pmohvE0BL9Wr0TFye9Kio=b4NxH5Niw@mail.gmail.com>
     [not found]                       ` <54DC34EF.4010204@eastlink.ca>
2015-02-12  5:30                         ` Bart Schaefer [this message]
2015-02-12  9:25                           ` Peter Stephenson
2015-02-12 16:43                             ` Bart Schaefer
2015-02-12 17:01                               ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150211213054.ZM19450@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).