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

Re: Mysterious (debug?) output in loop

You can find some other useful options here: https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html#std-options

niedz., 29 sty 2023, 21:19 użytkownik Dominik Vogt <dominik.vogt@xxxxxx> napisał:
Running this script

--- snip ---
emulate zsh
repeat 3; do
        local FOO
--- snip ---

Produces this output:

  $ ./foo

  $ 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?  Is that some forgotten debug
output?  Is there a way to disable that (without writing the
script in a different way)?

Of course I'm aware that (a) using local variables in global scope
is useless and (b) variables are local to functions, not local to
loops.  Before stripping down the test case, it was some code in a
function.  Moving 'local FOO' out of the loop, or replacing it
with 'local FOO="0"' suppresses the output.


Dominik ^_^  ^_^


Dominik Vogt

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