Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[RFC or so] Add HASH_LOOKUP option
- X-seq: zsh-workers 28193
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: [RFC or so] Add HASH_LOOKUP option
- Date: Mon, 23 Aug 2010 16:09:45 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=hD1i/6PmrhbjbifrUWiuVI2fLllylJO36jnDwdp9hhM=; b=dfKYiQ42g3nI9xKm1FNcqHdKhCzDBws/+xQLLuT37xqJL/jbSua5TI357Qw584JRww ValUFV3WIe/xlWFp8K6Utus4r99TNWohf1m81CNpVZWvYRmjhq8TsqKpO9bCOsplF+6f RxTkoEPx0SAWwcUwS8Pn0ByP6v5h4H4xNGrcM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=PQ5pxjf/+gu+668XRTuuh6JcSyB4hd+ykB+tEP3Jem1jPhoMUO74BrPEe5w2IpK2Ch 0pzBO0fnooIrxaTfRRz7jbtF0DCeWwqfH/RwnkJtPiACAwpzXHOK8SVP+tSs1f1+FKi3 ZFOXcKd5e6webUHYrA+qQFDmlen6JroeGQFfQ=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
When this is unset, external commands are always resolved with a full
path search, but still inserted into the hash for spell correction if
those options are on.
Caveat: I have not verified all possible paths that use the hash check
for this, but at least =cmd and which -p cmd and actually running cmd
do check it.
---
This was motivated by wycats (Yehuda Katz) on IRC having troubles with
his users running gem install bundler or so, and then getting
segfaults because of mismatches between ruby versions and whatnot, and
they didn't know to run rehash. Adding this option of course doesn't
help him that much since I'm not sure if A) we want to 1) have it at
all 2) default it to on B) it would reach distros anytime soon.
Also by the fact that doing a full path search is probably not that
slow for most people, and I know that some people have resorted to
putting hash -r in their precmd() functions which is of course slower
than just doing the path search since HASH_DIRS defaults to on.
If it turns out to be a good idea, I will of course include
documentation in the followup patch, but for now I won't bother.
Src/exec.c | 10 ++++++++--
Src/options.c | 1 +
Src/zsh.h | 1 +
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Src/exec.c b/Src/exec.c
index 93d1b26..9a488fe 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -754,7 +754,7 @@ findcmd(char *arg0, int docopy)
}
break;
}
- if (cn) {
+ if (cn && isset(HASHLOOKUP)) {
char nn[PATH_MAX];
if (cn->node.flags & HASHED)
@@ -2708,7 +2708,13 @@ execcmd(Estate state, int input, int output,
int how, int last1)
char **checkpath = pathchecked;
int dohashcmd = isset(HASHCMDS);
- hn = cmdnamtab->getnode(cmdnamtab, cmdarg);
+ if (isset(HASHLOOKUP))
+ hn = cmdnamtab->getnode(cmdnamtab, cmdarg);
+ else {
+ hn = NULL;
+ dohashcmd = 1;
+ checkpath = path;
+ }
if (hn && trycd && !isreallycom((Cmdnam)hn)) {
if (!(((Cmdnam)hn)->node.flags & HASHED)) {
checkpath = path;
diff --git a/Src/options.c b/Src/options.c
index dedbf0c..fe720fd 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -141,6 +141,7 @@ static struct optname optns[] = {
{{NULL, "hashcmds", OPT_ALL}, HASHCMDS},
{{NULL, "hashdirs", OPT_ALL}, HASHDIRS},
{{NULL, "hashlistall", OPT_ALL}, HASHLISTALL},
+{{NULL, "hashlookup", OPT_ALL}, HASHLOOKUP},
{{NULL, "histallowclobber", 0}, HISTALLOWCLOBBER},
{{NULL, "histbeep", OPT_ALL}, HISTBEEP},
{{NULL, "histexpiredupsfirst",0}, HISTEXPIREDUPSFIRST},
diff --git a/Src/zsh.h b/Src/zsh.h
index 4485bd3..1dd5760 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1928,6 +1928,7 @@ enum {
HASHCMDS,
HASHDIRS,
HASHLISTALL,
+ HASHLOOKUP,
HISTALLOWCLOBBER,
HISTBEEP,
HISTEXPIREDUPSFIRST,
--
1.7.2
http://git.mika.l3ib.org/?p=zsh-cvs.git;a=patch;h=5e75cf283aa470ac28c94c6c3dd9e2bb0ea9cec1
if anyone actually wants to try it since I usually post garbled
patches.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author