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

Re: ksh autoloading

Roderick Schertler wrote:
>Well, of course, if the function is written knowing it could run under
>ksh or zsh then it can be made to work.  The problem is that a function
>which was written in ksh style will suddenly stop working (on first

That used to be the case for *all* ksh style functions.  With this
patch in place, the most common case by far -- a single function with
no initialisation code -- is handled properly.

>I don't see how the zsh behavior is superior, and I do see advantages to
>the ksh behavior.

With zsh, you can have a file that is used both as an autoloaded shell
function and as a shell script.  It also makes it impossible to have
an autoloaded shell function that, when successfully autoloaded, still
isn't defined.

>Consider a file which provides 3 tightly related functions and runs some
>initialization code.  I used such a think for directory stack handling
>in ksh, eg.  In ksh you link it to the 3 names.  In zsh you have to do
>some work.

OK, use the line

[[ -n "${ZSH_VERSION+set}" ]] && "$0" "$@"

instead of what I previously suggested.

>I wanted to be sure you knew you were breaking ksh compatibility.

We never had complete ksh compatibility anyway.  Perhaps we need an
option to behave exactly like ksh here, i.e., just source the file before
running the function.

I look on the patch as improving zsh compatibility.  It means that any
function written in the zsh style (except for the one perverse case of
a function that does nothing but redefine itself) will work as expected.


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