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

Re: `whence -v X` shows file for functions, but not alias; workaround?



On Thu, 12 Jan 2017, Eric Cook wrote:

> On 01/12/2017 12:24 PM, Timothee Cour wrote:
> > * how do i search for where an alias is defined?
> > `whence -v my_function`: works
> > my_function is a shell function from /home/timothee/.zshrc
> >
> > `whence -v my_alias`: doesn't do that:
> > my_alias is an alias for ...
> > Could that be implemented? What's a workaround? (besides grep of course)
> >
> > * why not also include line info?
> >
> zsh -lxic : 2> >(grep -F '> alias')

That only works if PS4 is not redefined somewhere in the init files, but
nice trick.

To answer the original question -- function objects track of all of this
information because of the delayed (auto)loading feature.  It was easy
to retain the information and add it to whence's output.  (Adding line
info would be additional work, that's why not.)

Aliases on the other hand use a simple generic hash table element that
doesn't have space for a source file name, so it would be a larger effort
to rewrite for that -- and it would double or more the amount of space
required to store aliases, whereas the space for functions was already
committed.

And in 20+ years I don't think anyone else has asked about it, so ...



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