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

Re: typeset -U within a function



Borsenkow Andrej <Andrej.Borsenkow@xxxxxxxxxxxxxx> writes:
> Vin Shelton wrote:
> 
> > From either zsh-4.0.4 or from the latest CVS sources, when I create a
> > function like this:
> > function bar {
> 
> >   typeset -U PATH
> >   PATH=/xxx:/yyy
> > }
> > and then run it, PATH is unchanged:
> 
> >
> 
> 
> 
> typeset -Ug PATH
> 
> typeset -U creates local variable.
> 
> -andrej

Ahh - I see.  Here's what the zshbuiltins man page has to say:

    A parameter is created for each name that does not already refer
    to one.  When inside a function, a new parameter is created for
    every name (even those that already exist), and is unset again
    when the function completes.  See `Local Parameters' in
    zshparam(1).  The same rules apply to special shell parameters,
    which retain their special attributes when made local.

Thanks, Andrej.

  - vin



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