zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: crash with error on initialisation
@ 2008-08-04 17:25 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2008-08-04 17:25 UTC (permalink / raw)
  To: Zsh hackers list

zsh crashes if there's an error on initialisation, for example if you
try to run a non-existent file.  This is because it can't load zsh/zle
because it hasn't set up the type table yet.  This causes a warning
which tries to load zshzle...  However, it doesn't need zsh/zle since
it's only trying to trash the command line which doesn't exist.

The fix is not to autoload for such things, which would cause zle to be
loaded in many cases when not needed.  This changed because I made
all functions load zsh/zle; this is obviously wrong.

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.88
diff -u -r1.88 init.c
--- Src/init.c	1 Aug 2008 13:53:45 -0000	1.88
+++ Src/init.c	4 Aug 2008 17:24:19 -0000
@@ -1206,14 +1206,22 @@
     /* autoload */
     switch (zle_load_state) {
     case 0:
-	if (load_module("zsh/zle", NULL, 0) != 1) {
-	    (void)load_module("zsh/compctl", NULL, 0);
-	    ret = zle_entry_ptr(cmd, ap);
-	    /* Don't execute fallback code */
-	    cmd = -1;
-	} else {
-	    zle_load_state = 2;
-	    /* Execute fallback code below */
+	/*
+	 * Some commands don't require us to load ZLE.
+	 * These also have no fallback.
+	 */
+	if (cmd != ZLE_CMD_TRASH && cmd != ZLE_CMD_RESET_PROMPT &&
+	    cmd != ZLE_CMD_REFRESH)
+	{
+	    if (load_module("zsh/zle", NULL, 0) != 1) {
+		(void)load_module("zsh/compctl", NULL, 0);
+		ret = zle_entry_ptr(cmd, ap);
+		/* Don't execute fallback code */
+		cmd = -1;
+	    } else {
+		zle_load_state = 2;
+		/* Execute fallback code below */
+	    }
 	}
 	break;
 

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-08-04 17:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-04 17:25 PATCH: crash with error on initialisation Peter Stephenson

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).