zsh-users
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: dominik.vogt@gmx.de, Zsh Users <zsh-users@zsh.org>
Subject: Re: Mysterious (debug?) output in loop
Date: Sun, 29 Jan 2023 21:20:56 +0100	[thread overview]
Message-ID: <CAN=4vMohQN5raK4M3AVkLps0T3qkSvM1J5+3u1-Juuu=g_ZkDQ@mail.gmail.com> (raw)
In-Reply-To: <Y9bTcNA8Har0xT6L@localhost>

On Sun, Jan 29, 2023 at 9:19 PM Dominik Vogt <dominik.vogt@gmx.de> 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.


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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-29 20:13 Dominik Vogt
2023-01-29 20:20 ` Roman Perepelitsa [this message]
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='CAN=4vMohQN5raK4M3AVkLps0T3qkSvM1J5+3u1-Juuu=g_ZkDQ@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=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).