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

Re: autoload



Bernd Eggink wrote:
> If a file contains more than one autoload function, strange things
> happen (3.1.2 and older versions):
> 
>   # File 'f1'
>   function f1() { print $0 $*; }
>   function f2() { print $0 $*; }
> 
> At the prompt, type
> 
>   autoload f1 f2
>   fpath=(.)
>   f1         # NOTHING HAPPENS!
>   functions  # shows that f1 und f2 are defined
>   f1         # now f1 is called!
> 
> Only if the definition of f2 is deleted from the file, the first call of
> f1 works. 

I think this has been tinkered about with at some stage, so it doesn't
quite behave the way the FAQ now claims:  I have to repost the FAQ (a bit
late) so I'll alter it.  The short answer is that in recent versions
of the shell you need to set the option kshautoload.  Otherwise,
the file is treated as containing a definition of the function
(rather than the body of the function) if and only if the file's
executable contents are just that definition and nothing else.  This
is to try and guess the user's intentions.  With kshautoload set it
does what you're expecting, no guessing.

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, Platanenallee 6, 15738 Zeuthen, Germany.



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