zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org, zsh-users@zsh.org
Subject: Re: new user questions and issues
Date: Sun, 10 May 2015 22:02:46 -0700	[thread overview]
Message-ID: <150510220246.ZM10136@torch.brasslantern.com> (raw)
In-Reply-To: <67F1153E-5D3C-4D29-BDD0-1BB9C71FF55A@gmail.com>

Most of this has been answered already, throwing one extra remark.

On May 6, 10:37am, Kannan Varadhan wrote:
}
} Issue #2.  Overridden local variables get echoed?

The tidbit that no one has explicitly mentioned is that "local" et al.
has function scope, so it makes no sense to declare something "local"
inside a loop body.  (In an if/else, it could make sense, as long as
the if/else is not itself inside a loop, but the variables declared
there will persist beyond the "fi".)

If you for some reason need a declaration to be local to a loop, use
an anonymous function context like this:

    local _t2
    for _t2 in 0 1 2 ; do
      function {
        local _t3
        _t3=XXX__${_t2}__
      }
    done


  parent reply	other threads:[~2015-05-11  5:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 17:37 Kannan Varadhan
2015-05-06 20:50 ` Eric Cook
2015-05-07 21:46   ` Kannan Varadhan
2015-05-07 21:54     ` ZyX
2015-05-11  5:02 ` Bart Schaefer [this message]
2015-05-11 17:43   ` Kannan Varadhan
2015-05-12  2:43     ` Bart Schaefer

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=150510220246.ZM10136@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).