zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: zsh hangs loading init files
Date: Sat, 7 Jan 2012 20:17:37 +0000	[thread overview]
Message-ID: <20120107201737.44b3162c@pws-pc.ntlworld.com> (raw)
In-Reply-To: <120106231700.ZM17143@torch.brasslantern.com>

On Fri, 06 Jan 2012 23:17:00 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Jan 6,  8:27pm, Greg Klanderman wrote:
> } hmm looks like users/14411
> 
> In that message, PWS pondered:
> 
> > I'm not sure why we don't check that commands are executables, was there
> > ever a reason?
> 
> Apparently the answer is "Yeah, if you've got 10,000 executables or
> a remote filesystem in your path, it takes a really long time to stat
> them all."

Not sure it's even worth making this an option, since it's going to have
to be off by default to avoid surprises and few people are going to
bother to turn it on, and mosth PATH directories only contain
executables anyway, but it's not much extra code.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.105
diff -p -u -r1.105 options.yo
--- Doc/Zsh/options.yo	28 Dec 2011 03:20:19 -0000	1.105
+++ Doc/Zsh/options.yo	7 Jan 2012 20:14:37 -0000
@@ -1155,6 +1155,20 @@ Whenever a command name is hashed, hash 
 as well as all directories that occur earlier in the path.
 Has no effect if neither tt(HASH_CMDS) nor tt(CORRECT) is set.
 )
+pindex(HASH_EXECUTABLES_ONLY)
+pindex(NO_HASH_EXECUTABLES_ONLY)
+pindex(HASHEXECUTABLESONLY)
+pindex(NOHASHEXECUTABLESONLY)
+cindex(hashing, of executables)
+cindex(executables, hashing)
+item(tt(HASH_EXECUTABLES_ONLY))(
+When hashing commands because of tt(HASH_COMMANDS), check that the
+file to be hashed is actually an executable.  This option
+is unset by default as if the path contains a large number of commands,
+or consists of many remote files, the additional tests can take
+a long time.  Trial and error is needed to show if this option is
+beneficial.
+)
 pindex(MAIL_WARNING)
 pindex(NO_MAIL_WARNING)
 pindex(MAILWARNING)
Index: Src/hashtable.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v
retrieving revision 1.34
diff -p -u -r1.34 hashtable.c
--- Src/hashtable.c	9 May 2011 10:38:02 -0000	1.34
+++ Src/hashtable.c	7 Jan 2012 20:14:37 -0000
@@ -663,8 +663,9 @@ hashdir(char **dirp)
 		 * This is the same test as for the glob qualifier for
 		 * executable plain files.
 		 */
-		if (stat(pathbuf, &statbuf) == 0 &&
-		    S_ISREG(statbuf.st_mode) && (statbuf.st_mode & S_IXUGO))
+		if (unset(HASHEXECUTABLESONLY) ||
+		    (stat(pathbuf, &statbuf) == 0 &&
+		     S_ISREG(statbuf.st_mode) && (statbuf.st_mode & S_IXUGO)))
 		    add = 1;
 	    }
 	    if (add) {
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.58
diff -p -u -r1.58 options.c
--- Src/options.c	8 Dec 2011 19:42:07 -0000	1.58
+++ Src/options.c	7 Jan 2012 20:14:37 -0000
@@ -140,6 +140,7 @@ static struct optname optns[] = {
 {{NULL, "globsubst",	      OPT_EMULATE|OPT_NONZSH},	 GLOBSUBST},
 {{NULL, "hashcmds",	      OPT_ALL},			 HASHCMDS},
 {{NULL, "hashdirs",	      OPT_ALL},			 HASHDIRS},
+{{NULL, "hashexecutablesonly", 0},                       HASHEXECUTABLESONLY},
 {{NULL, "hashlistall",	      OPT_ALL},			 HASHLISTALL},
 {{NULL, "histallowclobber",   0},			 HISTALLOWCLOBBER},
 {{NULL, "histbeep",	      OPT_ALL},			 HISTBEEP},
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.176
diff -p -u -r1.176 params.c
--- Src/params.c	4 Jan 2012 22:35:55 -0000	1.176
+++ Src/params.c	7 Jan 2012 20:14:38 -0000
@@ -3780,9 +3780,6 @@ static struct localename {
 #ifdef LC_TIME
     {"LC_TIME", LC_TIME},
 #endif
-#ifdef LC_ALL
-    {"LC_ALL", LC_ALL},
-#endif
     {NULL, 0}
 };
 
@@ -3791,6 +3788,10 @@ static void
 setlang(char *x)
 {
     struct localename *ln;
+    char *x2;
+
+    if ((x2 = getsparam("LC_ALL")) && *x2)
+	return;
 
     /*
      * Set the global locale to the value passed, but override
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.178
diff -p -u -r1.178 zsh.h
--- Src/zsh.h	8 Dec 2011 19:42:07 -0000	1.178
+++ Src/zsh.h	7 Jan 2012 20:14:38 -0000
@@ -1986,6 +1986,7 @@ enum {
     GLOBSUBST,
     HASHCMDS,
     HASHDIRS,
+    HASHEXECUTABLESONLY,
     HASHLISTALL,
     HISTALLOWCLOBBER,
     HISTBEEP,

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2012-01-07 20:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05 16:44 Greg Klanderman
2012-01-05 19:35 ` Dan Nelson
2012-01-07  1:12   ` Greg Klanderman
2012-01-07  1:27     ` Greg Klanderman
2012-01-07  1:28     ` Mikael Magnusson
2012-01-07  1:36       ` Greg Klanderman
2012-01-07  1:56         ` Mikael Magnusson
2012-01-07  7:17           ` Bart Schaefer
2012-01-07 20:17             ` Peter Stephenson [this message]
2012-01-09 20:19               ` Greg Klanderman

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=20120107201737.44b3162c@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /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).