Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Interrupting globs (Re: Something rotten in tar completion)



On Mon, 8 Dec 2014 13:43:11 +0100
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> Test case for you guys:
> % zsh -f
> % precmd() echo yes
> % sleep 2; echo no
> ^C
> yes

I will assume it's uncontroversial that we do want the yes and not the
no.  It looks reasonable.  (As an entirely separate matter, I wonder if
precmd should have the error status available to it?)

> With :/'Ensure propagation' and :/'Put back' (eg, current tip of
> interrupt_abort), I get neither printed.
>
> So I guess some other place needs to clear interrupts as well, or the
> "return to commandline" clear should be before precmd being called?
> (If that's nonsense it's because I haven't looked at the code for that
> at all).

I think we should clear it before and after precmd to be safe.

It's not really clear to me why this worked before; one of the various
other errflag-clearings must have come in before we reached the
top-level loop.  I'm not sure if that was intentional or accidental, but
presumably somewhere high up in loop() with toplevel == 1 is right.  I
can't work out if it should be even higher, before the history mechanism
starts.

pws

diff --git a/Src/init.c b/Src/init.c
index 3cbd4e5..3059087 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -118,6 +118,14 @@ loop(int toplevel, int justonce)
 	    if (interact && toplevel) {
 	        int hstop = stophist;
 		stophist = 3;
+		/*
+		 * Reset all errors including the interrupt error status
+		 * immediately, so preprompt runs regardless of what
+		 * just happened.  We'll reset again below as a
+		 * precaution to ensure we get back to the command line
+		 * no matter what.
+		 */
+		errflag = 0;
 		preprompt();
 		if (stophist != 3)
 		    hbegin(1);



Messages sorted by: Reverse Date, Date, Thread, Author