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

Re: autoload

I decided I should clarify something:

On Sep 17, 10:34am, Bart Schaefer wrote:
} I think the problem here is that you've put a .zwc file IN a directory
} that is itself listed in $fpath.  This is typically a no-no.  You want
} a .zwc file to be treated as if it WERE a directory, NOT as if it were
} one of the function definition files IN the directory.

This is not quite correct.  I thought the situation was that we were
talking about was

    fpath=(/path/to/Directory ...)
    /path/to/Directory/Directory.zwc	# contains multiple functions

This would be wrong.  Instead it should be one of

    fpath=(/path/to/Directory ...)
    /path/to/Directory.zwc		# contains multiple functions
    fpath=(/path/to/Directory ...)
    /path/to/Directory/function.zwc	# contains one function only

In fact what Debian has done is the first of those two (correct) options,
so my "typically a no-no" was off base.

A third correct option would be

    fpath=(/path/to/Directory.zwc ...)

which I prefer, but which skips comparing the modification time of that
file to the files in /path/to/Directory/.  The advantage is that the
Directory itself need not exist, you can put the .zwc file anywhere.

Now, here's the interesting twist to what Debian has done.  They have

fpath=(... /usr/share/zsh/functions/Completion ...
       /usr/share/zsh/functions/Completion/Base ...)

with file /usr/share/zsh/functions/Completion/Base.zwc (among others).

For autoload, this is ambiguous -- if someone tries to run a command
named "Base", zsh searches /usr/share/zsh/functions/Completion/Base.zwc
for that function, because it might be the "one function only" option
described above.  It won't find the function there, of course, so it
will go on and look elsewhere and no one the wiser, and probably no one
ever runs "Base" anyway.

I don't want to claim there is anything wrong with Debian's choice, I
merly point it out as a probably-unintended side effect.

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