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

Re: Re-loading files loaded via "autoload"



On Wed, 2021-08-11 at 20:25 +0200, Mikael Magnusson wrote:
> eg, we have this, which mentions it in a comment of the example code:
>        It is also possible to create a function that is not  marked
> as  autoloaded,
>        but which loads its own definition by searching fpath, by using
> `autoload -X'
>        within a shell function.  For example, the following are equivalent:
> 
>               myfunc() {
>                 autoload -X
>               }
>               myfunc args...
> 
>        and
> 
>               unfunction myfunc   # if myfunc was defined
>               autoload myfunc
>               myfunc args...

I use this function as a convenience when I work on autoloaded
functions:

   autoreload () {
   	emulate -L zsh
   	local i
   	for i in $@
   	do
   		(( $+functions[$i] )) && unfunction $i
   		autoload -U $i
   	done
   }

Phil.





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