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

Re: PATCH: ksh_autoload safety cleanup



On Fri, 11 Jul 2008 01:32:03 -0700
Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> I'd naively interpret that to mean that the ksh_autoload setting at the
> time of the autoload/typeset determines it, rather than the value at the
> time the function is eventually loaded.  I'm not convinced that the
> current behaviour is correct and am wondering if the -k/-z should be
> implicitly provided instead.  Is there any situation where declaring
> autoload in one mode and then loading later in the other mode is likely
> to be correct and/or desired?

I don't imagine so, but the option was only designed as a single global
setting so that users wouldn't need to think about it, so it's not
surprising it doesn't work very well as a dynamic option and it's
probably too late to change.  If you use both regularly you need the
flags.

You can in any case already handle this along the lines of (this
isn't a complete replacement but it gives you the idea):

autoload() {
  if [[ -o kshautoload ]]; then
    builtin autoload -k "$@"
  else
    builtin autoload -z "$@"
  fi
}

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/




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