about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Doc/Zsh/options.yo14
-rw-r--r--Src/hashtable.c5
-rw-r--r--Src/options.c1
-rw-r--r--Src/zsh.h1
4 files changed, 19 insertions, 2 deletions
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 4bf55fa0c..dd237c0ef 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1155,6 +1155,20 @@ Whenever a command name is hashed, hash the directory containing it,
 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)
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 6fca256e3..775b6a277 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -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) {
diff --git a/Src/options.c b/Src/options.c
index a70d4ff11..5fbb06b11 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -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},
diff --git a/Src/zsh.h b/Src/zsh.h
index dda2fa91a..29c8a8319 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1986,6 +1986,7 @@ enum {
     GLOBSUBST,
     HASHCMDS,
     HASHDIRS,
+    HASHEXECUTABLESONLY,
     HASHLISTALL,
     HISTALLOWCLOBBER,
     HISTBEEP,