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

Re: Mysterious (debug?) output in loop



On Sun, Jan 29, 2023 at 9:19 PM Dominik Vogt <dominik.vogt@xxxxxx> wrote:
>
> Running this script
>
> --- snip ---
> #!/usr/bin/zsh
> emulate zsh
> repeat 3; do
>         local FOO
>         FOO="0"
> done
> --- snip ---
>
> Produces this output:
>
>   $ ./foo
>   FOO=0
>   FOO=0
>
>   $ zsh --version
>   zsh 5.8 (x86_64-debian-linux-gnu)
>
> Why does it print 'FOO=0' to stdout (not stderr) in all passes of
> the loop except the first one?

That's what `local` does by default. You can `setopt typeset_silent`
to disable this (I always do in all my scripts).

Roman.




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