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

Re: order of sourcing

On Tue, Jan 17, 2023 at 1:24 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
> The standard solution is to autoload functions. It solves a bunch of
> other problems that you get when sourcing files with function
> definitions

One complication here is that, if Ray is able to use "source" to load
a function's definition, then he's not writing the file in the
ordinary autoload format -- that is, the file must in fact contain the
  funcname() {
   # funcbody
whereas an autoload would normally be a file named "funcname"
containing only the function body.  To make autoloading work with
files designed to be sourced, one must employ additional tricks, such
as using "autoload -k".  Also, this remark --

> > run into 'not found' issues, like some subsidiary function has been
> > 'lost'.

-- also makes me suspect that Ray has more than one function per file,
which further messes with autoload.

> - You can rely on there being no aliases when the function is parsed.

That needs "autoload -U" I think?

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