zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: crash with error on initialisation
Date: Mon, 04 Aug 2008 18:25:12 +0100	[thread overview]
Message-ID: <25746.1217870712@csr.com> (raw)

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


                 reply	other threads:[~2008-08-04 17:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25746.1217870712@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).