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

Re: Suggestion: Allow whence to report path(s) for autoloaded functions

On Sat, Apr 25, 2009 at 12:55 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> I had something of an afterthought on this one ...
> On Apr 21, Â2:14pm, Ian Tegebo wrote:
> }
> } It seems like 'whence -v _MYFUNC' is the intuitive place to look for
> } this behavior. ÂI'd imagine it working like:
> }
> } $ whence -v _MYFUNC
> } _MYFUNC is a shell function defined in /blah/path/_MYFUNC
> This information could be misleading. ÂFunctions are not always loaded
> from $fpath; they can be defined in init files, edited and/or hand-
> entered on the command line, etc. ÂTo make whence useful, the shfunc
> structure would have to record where the function came from, or whence
> must only report the above if the function has NOT YET been loaded.
> There's also the question of what to do about files that are found in
> the $fpath directories but are not marked for autoloading.
> } Consequently, removing the '&& break' provides the expected result for
> } 'whence -a':
> }
> } $ whence -av _MYFUNC
> } _MYFUNC is a shell function defined in /blah/path_one/_MYFUNC
> } _MYFUNC is a shell function defined in /blah/path_two/_MYFUNC
> That's also misleading. ÂIf _MYFUNC were an executable located in two
> directories, it would be possible to explicitly choose which to run
> by typing the full path name as reported by whence. ÂFor a function,
> there's no [straightforward] way to bypass the fpath search order.
> (The non-straightforward way is to run
> Â ÂFPATH=/blah/path_two:"$FPATH" _MYFUNC
> but that can produce unexpected results if _MYFUNC calls autoloaded
> functions that should come from /blah/path_one instead.)
Thanks for that.

Obviously, I didn't fully appreciate how specific my use case was (nor
did I know about the idiom Peter suggested).  Now I realize I only
wanted a quick way to resolve a named file within a PATH-like
structure, and not the more general case about functions that my
suggestion implied.

Ian Tegebo

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