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

Re: Crash of 4.2.0-dev-1



On Apr 11, 10:40pm, Geoff Wing wrote:
}
} : Because files loaded with kshautoload have to contain the full function
} : definition
} 
} OK, according to the manual zshbuiltins(1) in autoload:
} 
}  ... With ksh-style autoloading, the contents of the file will not be
}      executed immediately.  Instead, the function created will contain
}      the contents of the file ...

Note that this excerpt applies specifically to +X with either -k or with
ksh_autoload set.  The trailing part you've omitted goes on:

   ... plus a call to the function itself appended to it ...

You have to look in zshmisc(1) under "Autoloading functions" to find the
real explanation of ksh_autoload:

       If the KSH_AUTOLOAD option is set, or  the  file  contains
       only  a simple definition of the function, the file's con-
       tents will be executed.  This  will  normally  define  the
       function in question, but may also perform initialization,
       which is executed in the context of  the  function  execu-
       tion, and may therefore define local parameters.  It is an
       error if the function is not defined by loading the  file.

       Otherwise,  the  function body (with no surrounding `func-
       name() {...}') is taken to be the complete contents of the
       file.  ...

} : Whereas zsh expects it to have been defined as:
} :
} :     kshtest () {
} : 	kshtest () {
} : 	    print "Running kshtest"
} : 	    unfunction kshtest
} : 	}
} : 	kshtest "$@"
} :     }
} 
} This is what I get.

If in fact your file "kshtest" contains exactly the two lines
	print "Running kshtest"
	unfunction kshtest
and you ran
	setopt ksh_autoload
	autoload +X -k kshtest
then it should be impossible for you to have gotten the kshtest-within-
kshtest form you just quoted.  If you *do* somehow get the nested def'n
shown above, then the bug *won't* be tickled -- the but only happens if
the nested kshtest def'n does *not* appear, but both the "unfunction"
and the call with "$@" *do* appear.



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