zsh-users
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: Jun T <takimoto-j@kba.biglobe.ne.jp>
Cc: zsh-users@zsh.org, Leander Jedamus <ljedamus@googlemail.com>
Subject: Re: possible bug in zsh concerning a for loop
Date: Fri, 18 Mar 2022 15:14:01 +0100	[thread overview]
Message-ID: <20220318141401.GC35304@zira.vinc17.org> (raw)
In-Reply-To: <646DEC1A-CEC9-47B7-9D90-954D213C25B5@kba.biglobe.ne.jp>

On 2022-03-18 17:45:22 +0900, Jun T wrote:
> You can get this by:
> 
> [1] use array (instead of scalar parameter items)
> 
> a=( item1 item2 item3 )
> for i in $a; do ... done
> 
> [2] use ${=items}
> 
> for i in ${=items}; do ... done
> 
> [3] set SH_WORD_SPLIT option
> 
> setopt SH_WORD_SPLIT
> for i in $items; do ... done
> 
> I prefer [1], but it is up to you which method you use.

[1] has the advantage that it supports arguments containing spaces.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


  reply	other threads:[~2022-03-18 14:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18  7:33 Leander Jedamus
2022-03-18  8:45 ` Jun T
2022-03-18 14:14   ` Vincent Lefevre [this message]
2022-03-18  8:21 Leander Jedamus
2022-03-18 10:12 Leander Jedamus

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=20220318141401.GC35304@zira.vinc17.org \
    --to=vincent@vinc17.net \
    --cc=ljedamus@googlemail.com \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    --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).