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

PATCH: crash with error on initialisation



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@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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