Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15478
| Path | csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Is this a bug by any chance? |
| Date | Mon, 7 Oct 2019 08:47:37 -0400 |
| Lines | 27 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1215.1570452489.2651.bug-bash@gnu.org> (permalink) |
| References | <99440807.4131727.1570301315442.ref@mail.yahoo.com> <99440807.4131727.1570301315442@mail.yahoo.com> <20191007124737.GM28751@eeg.ccf.org> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | usenet.stanford.edu 1570452490 4421 209.51.188.17 (7 Oct 2019 12:48:10 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | "bug-bash@gnu.org" <bug-bash@gnu.org> |
| To | George R Goffe <grgoffe@yahoo.com> |
| Envelope-to | bug-bash@gnu.org |
| Mail-Followup-To | George R Goffe <grgoffe@yahoo.com>, "bug-bash@gnu.org" <bug-bash@gnu.org> |
| Content-Disposition | inline |
| In-Reply-To | <99440807.4131727.1570301315442@mail.yahoo.com> |
| User-Agent | Mutt/1.10.1 (2018-07-13) |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] |
| X-Received-From | 139.137.100.1 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <https://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <20191007124737.GM28751@eeg.ccf.org> |
| X-Mailman-Original-References | <99440807.4131727.1570301315442.ref@mail.yahoo.com> <99440807.4131727.1570301315442@mail.yahoo.com> |
| Xref | csiph.com gnu.bash.bug:15478 |
Show key headers only | View raw
On Sat, Oct 05, 2019 at 06:48:35PM +0000, George R Goffe via Bug reports for the GNU Bourne Again SHell wrote:
> I was expecting to see:
> 12345
> #!./bash -xv
> x="1 2 3 4 5"
> for z in "$x"
> do
> echo "$z"
> done
> exit 0
Not a bug. You've created a string of length 9 characters, and
you've told bash to iterate once, using this string as the contents of
variable z.
If you want to create a *list* and iterate over that list, one element
at a time, use arrays instead of string variables.
x=(1 2 3 4 5)
for z in "${x[@]}"; do
echo "$z"
done
See <https://mywiki.wooledge.org/BashGuide/Arrays> and
<https://mywiki.wooledge.org/BashFAQ/005>.
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Is this a bug by any chance? Greg Wooledge <wooledg@eeg.ccf.org> - 2019-10-07 08:47 -0400
csiph-web