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

Re: Local variable declaration in loops buglet...



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:

> On Nov 4,  4:06pm, Philippe Troin wrote:
> }
> }   ceramic% foo() { for i in 1 2 3; do local x; x=$i;done }
> } 
> } Moving the local out of the loop fixes the echo of course... But I do
> } not think it should matter.
> 
> This is not a bug, it's documented behavior of `typeset' for which
> `local' is an alias:
> 
>     For each remaining name that refers to a parameter that is set,
>     the name and value of the parameter are printed in the form of an
>     assignment. Nothing is printed for newly-created parameters, or when
>     any attribute flags listed below are given along with the name.
> 
> In 4.1.1-dev, you can `setopt typeset_silent' to suppress this.

Oops. Did not know this behavior. Sorry for the noise.

Phil.



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