zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Peng Yu <pengyu.ut@gmail.com>
Cc: zsh-users <zsh-users@zsh.org>
Subject: Re: numeric for-loop and string for-loop
Date: Mon, 3 Dec 2018 15:58:50 +0100	[thread overview]
Message-ID: <CAHYJk3TRw3+y+1x0rO-RXPRw_03E=Ux8TU5=Q+zS6YxiF-oKpw@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3R7OvA07chXGWmkMpSi0fB21z06V-2BJ5=3R+_14GJAew@mail.gmail.com>

On 12/3/18, Mikael Magnusson <mikachu@gmail.com> wrote:
> % a=5+5 b=2\*3
> % typeset -i i
> % for i in a b; do declare -p i; done; declare -p a b
> typeset -i i=10
> typeset -i i=6
> typeset a=5+5
> typeset b='2*3'
>
> If this is not what you want, you can use unset i before each loop.

In fact, bash will act the same way as zsh if you say "typeset -i i",
the only difference is that zsh will create parameters as integers in
a mathematical context if they did not previously exist. In other
words, your zsh script will also "work" if you do "typeset i" before
the first loop, because then it already exists when you get to the
math loop.

-- 
Mikael Magnusson

      reply	other threads:[~2018-12-03 14:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20181203135826epcas1p4dbee2d63b98245bd84c3179f644d2e6c@epcas1p4.samsung.com>
2018-12-03 13:56 ` Peng Yu
2018-12-03 14:48   ` Peter Stephenson
2018-12-03 14:53   ` Mikael Magnusson
2018-12-03 14:58     ` Mikael Magnusson [this message]

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='CAHYJk3TRw3+y+1x0rO-RXPRw_03E=Ux8TU5=Q+zS6YxiF-oKpw@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=pengyu.ut@gmail.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).