Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: whence (was Re: local unfunction)
- X-seq: zsh-users 23297
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: whence (was Re: local unfunction)
- Date: Sat, 31 Mar 2018 18:18:36 -0700
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Quui5Qdi+/9r0nKdfVohXlcoPsGk0rOJmY2D1UBLCuI=; b=RqiCLEtqVtOTk6aWBPCMJKxC5aG06SbzbH87dN4zF3M6uy2t+3PcprsPvf0wd/ltT8 EseHZ+hY2JLqhPHsjNLoS4uCrtKLEDWFGsgKHHPro2RFisQBCqChammNvVEoUzYPATtH TJMocFHsy2BoCeFeisilHt6ZKz+kP1YVLP1hImxt6ZwT8a6UJz+kxYnKQpjSKqpAP3HY Zj2uUFxz5eFOepMXVw8dtCPO3mXKkUQG6jb8Pd8zQsT0BMatIzb4fiBFT54KBdHlENdv E3RAlhPHHoykmzU+y/sO32pOqIyI+KJEz5lWP+kv8n0Zg1LM1K7LeB+oRpsFfokP0AqI SNGg==
- In-reply-to: <6935145d-785f-f2dd-d4f2-e7ea627e2bc3@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAH+w=7Zz4HMfB_RA5nHr_i_iwKvD=S0QOjcogc0Y0OYSXv0JXw@mail.gmail.com> <6935145d-785f-f2dd-d4f2-e7ea627e2bc3@eastlink.ca>
On Sat, Mar 31, 2018 at 10:21 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author