From: Bart Schaefer <schaefer@brasslantern.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: whence (was Re: local unfunction)
Date: Sat, 31 Mar 2018 18:18:36 -0700 [thread overview]
Message-ID: <CAH+w=7ane3_cT75hyZYp_4Zd1aT1eeDbbW9CVpBTZjAhKFQ+Qw@mail.gmail.com> (raw)
In-Reply-To: <6935145d-785f-f2dd-d4f2-e7ea627e2bc3@eastlink.ca>
On Sat, Mar 31, 2018 at 10:21 AM, Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> $ whence -wm "zsh*"
> zsh: command
> zsh5.3: command # binary
> zsh5.3:: command # text file
What's with the extra ":" there? Is there actually a colon in the file name?
> ... I've yet to understand what the point of the '-w' switch is.
% zsh() { print nope }
% alias zsh='print not this either'
% whence -w zsh
zsh: alias
% whence -wa zsh
zsh: alias
zsh: function
zsh: command
%
> -a # keep looking after the first match (the one to be executed) is found
So far so good.
> -m # find all matches of a pattern, subsumes '-a' (executable ONLY unless
> ... )
No, this does not subsume -a, because it will only return hits from
the internal hash tables. Thus if you have a file named "zsh" in 3
different directories in $path, the command hash table will contain
only the first of those, and whence -m will find only that one.
However, if you have three differently-named files matching "zsh*" in
$path, they will all have separate entries in the command hash table,
and whence -m will list all three.
> -t # Show non executable (text?) files as well, obviates -a, subsumes 'm'.
This being a proposed new flag. I think this points to the source of
the confusion. The command hash table will contain the first
occurrence of every file name from every directory in $path, even if
that first occurrence is not executable, and "whence -m" will show you
all of the matching entries in the hash table. The existing -m option
subsumes your -t.
The other confusion is that -m never searches $path. It always
populates the command hash table if necessary and then searches the
hash table.
% path=(./Src $path)
% whence zsh
./Src/zsh
% whence -a zsh
./Src/zsh
/bin/zsh
% whence -m zsh
/bin/zsh
%
There's one magic side-effect of combining -a and -m, which is that -m
will find something in the hash table and then -a will search $path
for what was found. That's a result of re-using the code that walks
the path to do the output formatting for the names found by -m.
next prev parent reply other threads:[~2018-04-01 1:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-31 15:25 Bart Schaefer
2018-03-31 17:21 ` Ray Andrews
2018-04-01 1:18 ` Bart Schaefer [this message]
2018-04-01 4:29 ` Ray Andrews
2018-04-01 17:33 ` Daniel Shahaf
2018-04-01 18:17 ` Bart Schaefer
2018-04-04 18:10 ` Daniel Shahaf
2018-04-05 0:20 ` Bart Schaefer
2018-04-05 1:41 ` Ray Andrews
2018-04-05 5:08 ` Bart Schaefer
2018-04-05 14:28 ` Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7ane3_cT75hyZYp_4Zd1aT1eeDbbW9CVpBTZjAhKFQ+Qw@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).