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

Re: Crash after interrupting tab-completion with Ctrl-\



On Oct 27,  3:40pm, Vincent Lefevre wrote:
} Subject: Re: Crash after interrupting tab-completion with Ctrl-\
}
} $ ls Mail/oldarc/cur/1[TAB]
} zsh: do you wish to see all 140500 possibilities (70251 lines)? 
} 
} Then I type 'y', followed by Ctrl-\.

Ok, so this isn't really a crash -- it's the default response to a QUIT
signal.  I just did a quick check and the QUIT handler is not reset, so
this is as expected, except that the stty quit character is supposed to
be disabled at this point (I think).  So the questions are:

- How did the quit character get re-enabled? - and

- Why doesn't INT work here?

I'm not too worried about the first one, since it seems to have been
fortuitous.  As for the latter, the following patch is not perfect --
it causes some screen-repaint problems if you manage to send the INT
before the first test of !errflag, and I may have gone overboard with
places the flag is tested -- but please see if it allows you to stop
that 70k-line listing.

Also fixed thinko in the _main_complete trap, although we've already
left _main_complete by the time printcomplist() is running.

diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index e881ea6..fcd6366 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -128,7 +128,7 @@ _completer_num=1
 
 # We assume localtraps to be in effect here ...
 integer SECONDS=0
-trap 'zle -M "Killed by signal in ${funcstack[0]} after ${SECONDS}s";
+trap 'zle -M "Killed by signal in ${funcstack[1]} after ${SECONDS}s";
       zle -R; return 130' INT QUIT
 
 # Call the pre-functions.
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 5e5ba9f..2e1a527 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1375,7 +1375,7 @@ compprintlist(int showall)
 	tcout(TCCLEAREOD);
 
     g = ((lasttype && lastg) ? lastg : amatches);
-    while (g) {
+    while (g && !errflag) {
 	char **pp = g->ylist;
 
 #ifdef ZSH_HEAP_DEBUG
@@ -1389,7 +1389,7 @@ compprintlist(int showall)
 		ml = lastml;
 		lastused = 1;
 	    }
-	    while (*e) {
+	    while (*e && !errflag) {
 		if (((*e)->count || (*e)->always) &&
 		    (!listdat.onlyexpl ||
 		     (listdat.onlyexpl & ((*e)->always > 0 ? 2 : 1)))) {
@@ -1469,11 +1469,11 @@ compprintlist(int showall)
 
 		nl = nc = g->lins;
 
-		while (n && nl--) {
+		while (n && nl-- && !errflag) {
 		    i = g->cols;
 		    mc = 0;
 		    pq = pp;
-		    while (n && i--) {
+		    while (n && i-- && !errflag) {
 			if (pq - g->ylist >= g->lcount)
 			    break;
 			if (compzputs(*pq, mscroll))
@@ -1582,7 +1582,7 @@ compprintlist(int showall)
 	    } else
 		p = skipnolist(g->matches, showall);
 
-	    while (n && nl--) {
+	    while (n && nl-- && !errflag) {
 		if (!lasttype && ml >= mlbeg) {
 		    lasttype = 3;
 		    lastg = g;
@@ -1596,7 +1596,7 @@ compprintlist(int showall)
 		i = g->cols;
 		mc = 0;
 		q = p;
-		while (n && i--) {
+		while (n && i-- && !errflag) {
 		    wid = (g->widths ? g->widths[mc] : g->width);
 		    if (!(m = *q)) {
 			if (clprintm(g, NULL, mc, ml, (!i), wid))



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