zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Vogt <dominik.vogt@gmx.de>
To: Zsh Users <zsh-users@zsh.org>
Subject: Mysterious (debug?) output in loop
Date: Sun, 29 Jan 2023 21:13:36 +0100	[thread overview]
Message-ID: <Y9bTcNA8Har0xT6L@localhost> (raw)

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


             reply	other threads:[~2023-01-29 20:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-29 20:13 Dominik Vogt [this message]
2023-01-29 20:20 ` Roman Perepelitsa
2023-01-29 20:22 ` Bart Schaefer
2023-01-30 10:12 ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y9bTcNA8Har0xT6L@localhost \
    --to=dominik.vogt@gmx.de \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).