From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10639 invoked by alias); 6 Nov 2014 21:15:55 -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: 33618 Received: (qmail 10014 invoked from network); 6 Nov 2014 21:15:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [80.3.229.105] X-Spam: 0 X-Authority: v=2.1 cv=Ku/D2AmN c=1 sm=1 tr=0 a=uz1KDxDNIq33yePw376BBA==:117 a=uz1KDxDNIq33yePw376BBA==:17 a=NLZqzBF-AAAA:8 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=BrDiTsk0AAAA:8 a=et4-uUl92sZppXjJoGgA:9 a=CjuIK1q_8ugA:10 Date: Thu, 6 Nov 2014 21:10:17 +0000 From: Peter Stephenson To: Zsh Hackers' List Subject: Re: 'whence' question Message-ID: <20141106211017.11b8848a@pws-pc.ntlworld.com> In-Reply-To: <141105204330.ZM2973@torch.brasslantern.com> References: <545A6D66.3080500@eastlink.ca> <1458.1415209763@thecus.kiddle.eu> <20141105180035.22f6e9b1@pwslap01u.europe.root.pri> <141105204330.ZM2973@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 05 Nov 2014 20:43:30 -0800 Bart Schaefer wrote: > On Nov 5, 6:00pm, Peter Stephenson wrote: > } Subject: Re: 'whence' question > } > } On Wed, 05 Nov 2014 18:49:23 +0100 > } Oliver Kiddle wrote: > } > Looking at the source, it seems that whence doesn't support both -a and > } > -m together though it doesn't produce an error. > } > } You're right: I think *that's* a bug. > > Hmm. This is more complicated than it at first appears. Moved to zsh-workers. Don't we want something like this? diff --git a/Src/builtin.c b/Src/builtin.c index 5b711ed..101c19a 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3228,11 +3228,39 @@ bin_whence(char *nam, char **argv, Options ops, int func) scanmatchtable(builtintab, pprog, 1, 0, DISABLED, builtintab->printnode, printflags); } - /* Done search for `internal' commands, if the -p option * - * was not used. Now search the path. */ - cmdnamtab->filltable(cmdnamtab); - scanmatchtable(cmdnamtab, pprog, 1, 0, 0, - cmdnamtab->printnode, printflags); + if (all) { + char **pp, *buf, *fn; + DIR *od; + + pushheap(); + for (pp = path; *pp; pp++) { + if (!**pp) + continue; + od = opendir(*pp); + if (!od) + continue; + + while ((fn = zreaddir(od, 0))) { + if (!pattry(pprog, fn)) + continue; + + buf = zhtricat(*pp, "/", fn); + + if (iscom(buf)) { + zputs(buf, stdout); + fputc('\n', stdout); + } + } + closedir(od); + } + popheap(); + } else { + /* Done search for `internal' commands, if the -p option * + * was not used. Now search the path. */ + cmdnamtab->filltable(cmdnamtab); + scanmatchtable(cmdnamtab, pprog, 1, 0, 0, + cmdnamtab->printnode, printflags); + } unqueue_signals(); } -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/