Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15477 > unrolled thread

Re: Is this a bug by any chance?

Started by"" <kfm@plushkava.net>
First post2019-10-05 20:43 +0100
Last post2019-10-05 20:43 +0100
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Is this a bug by any chance? "" <kfm@plushkava.net> - 2019-10-05 20:43 +0100

#15477 — Re: Is this a bug by any chance?

From"" <kfm@plushkava.net>
Date2019-10-05 20:43 +0100
SubjectRe: Is this a bug by any chance?
Message-ID<mailman.1058.1570304608.2651.bug-bash@gnu.org>
On Sat, 5 Oct 2019 18:48:35 +0000 (UTC)
George R Goffe via Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org> wrote:

> Hi,
> 
> I just built the latest bash in an effort to determine if thie script shows a bug or a ufu. Can you help me please?
> 
> I was expecting to see:
> 12345
> 
> Best regards AND thanks for your help,
> 
> George...
> 
> #!./bash -xv
>  x="1 2 3 4 5"
> + x='1 2 3 4 5'
>  for z in "$x"
>     do
>        echo "$z"
>     done
> + for z in "$x"
> + echo '1 2 3 4 5'
>  1 2 3 4 5
>  exit 0
> + exit 0
> 
> 

It's definitely not a bug. Quoting the expansion inhibits word splitting. Your loop iterates once over a single word. Said word is conveyed to echo as a single argument. In this case, said argument is printed by echo, with the addition of a newline character. If your ultimate intent is to store an arbitrary list of strings in a variable prior to iterating over them, you should use an array variable instead. As such, this would be a topic better suited to the help-bash list.

-- 
Kerin Millar

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web