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

Re: How sensible is ... ?



Phil Pennock wrote:
> I found that using 'alias' inside there failed to work (in an autoloaded
> function anyway) and had to convert to a function.

That's a general feature.

% testal() { al='print alias'; al; }
% testal
zsh: command not found: al

The entire function is parsed before the alias is defined, so the `al'
never gets expanded.  A script is parsed line by line, so this doesn't
happen.

> And useing 'typeset
> -f leavecmd' then defining it after a possible 'setopt localfunctions',
> it remained in scope. I'm at work and decided against spending more time
> on that so just used TRAPEXIT to unfunction it -- maybe I'm just doing
> something wrong ...

I don't think there is another way of making functions have local
scope at the moment.

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



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