From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9690 invoked by alias); 23 Aug 2010 14:09:54 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28193 Received: (qmail 6200 invoked from network); 23 Aug 2010 14:09:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.83.171 as permitted sender) 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= MIME-Version: 1.0 Date: Mon, 23 Aug 2010 16:09:45 +0200 Message-ID: Subject: [RFC or so] Add HASH_LOOKUP option From: Mikael Magnusson To: zsh workers Content-Type: text/plain; charset=UTF-8 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