Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 'whence' question
- X-seq: zsh-workers 33618
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Subject: Re: 'whence' question
- Date: Thu, 6 Nov 2014 21:10:17 +0000
- In-reply-to: <141105204330.ZM2973@torch.brasslantern.com>
- 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
- References: <545A6D66.3080500@eastlink.ca> <1458.1415209763@thecus.kiddle.eu> <20141105180035.22f6e9b1@pwslap01u.europe.root.pri> <141105204330.ZM2973@torch.brasslantern.com>
On Wed, 05 Nov 2014 20:43:30 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Nov 5, 6:00pm, Peter Stephenson wrote:
> } Subject: Re: 'whence' question
> }
> } On Wed, 05 Nov 2014 18:49:23 +0100
> } Oliver Kiddle <okiddle@xxxxxxxxxxx> 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 <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author