zsh-users
 help / color / mirror / code / Atom feed
* Mysterious (debug?) output in loop
@ 2023-01-29 20:13 Dominik Vogt
  2023-01-29 20:20 ` Roman Perepelitsa
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dominik Vogt @ 2023-01-29 20:13 UTC (permalink / raw)
  To: Zsh Users

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?  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.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-30 10:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-29 20:13 Mysterious (debug?) output in loop Dominik Vogt
2023-01-29 20:20 ` Roman Perepelitsa
2023-01-29 20:22 ` Bart Schaefer
2023-01-30 10:12 ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).