Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: leading zeros in for/foreach loops
- X-seq: zsh-users 21294
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: leading zeros in for/foreach loops
- Date: Mon, 15 Feb 2016 10:59:57 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=NC50TprKVfwAf4WFBCEbPgpPNQFQE5xijJ7U8QrbDBE=; b=BKPAMZSYNbUtMcJAXRs2hWEuEUXeCr3GkvdSbWB99hutwTuVD+o7oexMHMoHtEplnK X1UdB8FQaaC5feIu3VYN5aW4rWcfSJkUIfJRRCGeqrITzJMUuUkHMVchkUcl17sXlLpU /luJyz0csW+tJ2VresRf9d0vbT0oJCfxJzqmrPrQBeKupUd0xnH8xWLyGy/yOJyiKMVB CJutVhBshjjudP3Bh5HFzKcCd07qoUczGkU4Plxpt63qaTOnsVAr31hgb54t08sRd1mh km1AqE7BWsY2BT0zJzNv+Hn6wxB+w41/NTNAX9SFBU4seQOKXDdgdXEdfdEZf9bhvUHL y76w==
- In-reply-to: <20160215180719.GA4146@spiegl.de>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20160215180719.GA4146@spiegl.de>
On Feb 15, 7:07pm, Andy Spiegl wrote:
}
} Can someone please explain this to me? Does this for loop do
} something strange with the variable "i"? How can I avoid that?
If the first assignment to an undeclared variable occurs in an
arithmetic context, the variable is given numeric type (integer or
float, depending on what has been assigned to it). "for (( ... ))"
syntax is such a context.
You can avoid this implicit declaration by explicitly declaring the
variable before using it in any of your loops, e.g., "typeset i" or
"declare i" or "local i" or the appropriate synonym. Or "unset i"
after the loop is finished.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author