Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 'whence' question

On Thu, Nov 6, 2014 at 1:45 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:

> On 11/05/2014 08:43 PM, Bart Schaefer wrote:
>> The pattern accepted by the -m option is not a glob,
> That seems very counterintuitive!  I'm taking it as a regular glob just
> as, I think,
> anyone would.

A "regular glob" and a pattern aren't significantly different, but for
example you can't use (most) glob qualifiers in a pattern, and the meaning
of "/" is very different.  Note that "whence" is not a file search tool;
scanning a hash table of alias names with a glob comparing file type or
modification time would make no sense.

Having just written that, it occurs to me that perhaps the "right way"
>> is the equivalent of this? --
>>         whence -a ${(k)commands[(I)pattern]}
> I couldn't get any love from that.

Interesting, it worked very nicely for me even as far back as zsh-4.2.6 on
an ancient virtual machine:

% whence -vsa ${(k)commands[(I)zsh*]}
zshenv not found
zsh is an alias for zsh-4.2.6
zsh is /usr/local/bin/zsh -> /bin/zsh
zsh is /bin/zsh
zsh.old is /bin/zsh.old
zshrc not found
zsh-4.2.0 is /bin/zsh-4.2.0
zsh-4.2.3 is /bin/zsh-4.2.3
zsh-4.2.5 is /bin/zsh-4.2.5
zsh-4.2.6 is /bin/zsh-4.2.6

That should find all the names in the command hash table that begin with
zsh, and then pass them all to whence to find the full paths.  I'm not sure
why zshrc and zshenv are in the command hash table.

Messages sorted by: Reverse Date, Date, Thread, Author