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

Really wierd problems with autoload



I have a function "zman" that gets set up in my .zshrc:
--------------------------------------------------------
zman() {
  local f
  for f in ${^fpath:-/usr/local/lib/zsh/functions}/run-help
  do
    if [[ -f $f && -r $f ]]
    then
        unalias run-help
        autoload run-help
        HELPDIR=/usr/local/lib/zsh/help
        FPATH=$f \run-help $1
        return $?
    elif [[ -f /usr/local/lib/zsh/help/$1 ]]
    then less /usr/local/lib/zsh/help/$1
    else man $1
    fi
  done
}
alias run-help zman
--------------------------------------------------------

This used to work, but in 3.1.6-dev-20 when I type ESC-h I get

run-help:9: run-help: function definition file not found

Now, it's not run-help line 9, it's zman line 9; and further by the time
zman finishes the function run-help IS correctly loaded, it just for some
reason won't execute.  Subsequent uses of ESC-h execute the new run-help.

But that's not the really wierd problem.

In my .zshenv is this snippet:
----------------------------------------------------------------------
# Subshell because some versions of zsh stop sourcing on "bad option"
if (autoload -U)
then
  fpath=(~/zshfun $fpath)
  autoload ~/zshfun/*(N.:t)
  # autoload -U ${^fpath[2,-1]}/*(N.:t)		# compinit handles this
else
  # This probably doesn't work in all versions
  fpath=(~/zshfun /usr/local/lib/zsh/functions)
  autoload $^fpath/*(N.:t)
fi
----------------------------------------------------------------------

This is supposed to set fpath correctly depending on whether the current
shell is 3.1.6+ (which has autoload -U) or not.

However, if I do this:

	export FPATH
	exec $ZSH_NAME

the (autoload -U) returns nonzero when the new shell starts up, even though
it really is 3.1.6-dev-20, and I end up with the wrong fpath so compinit
fails, etc.  Once I've actually got a prompt, I can run (autoload -U) with
or without the subshell and get a zero exit status, but for some strange
reason it fails during reading of the .zshenv when there's an FPATH in the
environment.  And it only happens on "exec", not upon running $ZSH_NAME as
a simple external command.

I noticed this because (wierd thing #3) FPATH becomes exported when zman
does "FPATH=$f \run-help $1" ... the old value of FPATH appears to be
restored properly after run-help fails, but if it was not exported before,
it is afterwards.

This is completely mystifying ... perhaps a garbage pointer is getting put
into the environment when FPATH is exported?  But what does that have to
do with autoload -U failing?  Maybe the whole subshell is crashing and the
fact that it's got an autoload command in it is a red herring?  But it
fails completely silently and without leaving a core file or anything.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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