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

Re: local after setopt allexport?



schaefer@xxxxxxxxxxxxxxxxxxxxxxx wrote:
> Great Manitoba!  Finally something that makes sense!  That would
> explain why "typeset" acts like "local" when used inside a function:
> because it *always* acts like "local".

That's mostly true of zsh too, with the exception that anything
exported becomes global, otherwise it was impossible to export anything
from a function.  Actually, the only difference there is that in zsh
you can't have `local -x', which you can in ksh; typeset -x in both
exports the variable globally.  In this case local and typeset behave
differently in ksh.

> What does ksh do with
> 
> 	FOO=bar
> 	export FOO
> 	typeset FOO=foo
> 
> ??  Does that make FOO local?

If called in a function it creates a new copy of FOO with the value
foo, leaving the exported value as bar.  Otherwise, it changes the
exported value.

None of this particularly increases my enthusiasm for either local
variable mechanism.

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



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