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

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



On Fri, 05 Dec 2014 00:20:23 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Dec 4,  5:12pm, Peter Stephenson wrote:
> }
> } It's always in _files or _path_files --- kind of where you'd expect from
> } the code you quoted.  I guess it's the glob that's not very
> } interruptible.
> 
> This seems to help:
> 
> diff --git a/Src/glob.c b/Src/glob.c
> index ca7bc44..b3903f2 100644
> --- a/Src/glob.c
> +++ b/Src/glob.c
> @@ -463,7 +463,7 @@ scanner(Complist q, int shortcircuit)
>      int errssofar = errsfound;
>      struct dirsav ds;
>  
> -    if (!q)
> +    if (!q || errflag)
>  	return;
>      init_dirsav(&ds);

Not for me: it's more basic than that.  The trap in _main_complete isn't
working *at all* --- or, rather, it's working too well, by trapping all
errors.

It's using an eval-style trap, so the "return" in it is forcing the
current function in the completion code to return with that status and
no error flagged.  That might have been good enough to interrupt a
simple case, but what's actually needed is returning non-zero from a
function-style trap, which causes the default signal handler to run ---
I should have spotted this at the time since I've had suspicions since
that trap turned up.

This actually prevents the message in the trap showing up --- we need
some cleverer zle trickery to do that --- and consequently the trap is
not actually any use as it stands.  But at least interruption is now
usable rather than unsuable.

diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index fcd6366..765fb4b 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -128,8 +128,11 @@ _completer_num=1
 
 # We assume localtraps to be in effect here ...
 integer SECONDS=0
-trap 'zle -M "Killed by signal in ${funcstack[1]} after ${SECONDS}s";
-      zle -R; return 130' INT QUIT
+TRPAINT TRAPQUIT() {
+  zle -M "Killed by signal in ${funcstack[1]} after ${SECONDS}s";
+  zle -R
+  return 130
+}
 
 # Call the pre-functions.
 
pws



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