Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh hangs loading init files
On Fri, 06 Jan 2012 23:17:00 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author