bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Severe Bash Bug with Arrays


From: Clark Wang
Subject: Re: Severe Bash Bug with Arrays
Date: Wed, 25 Apr 2012 13:23:18 +0800

On Wed, Apr 25, 2012 at 07:21, Ted Okuzumi <tedokuzumi@gmail.com> wrote:

> I am writing this e-mai to report to report a bug in bash.
>
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
> -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale'
> -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib
> -g \
> -O2
> uname output: Linux concour5 2.6.18-274.3.1.el5xen #1 SMP Tue Sep 6
> 20:57:11 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-unknown-linux-gnu
>
> Bash Version: 4.2
> Patch Level: 0
> Release Status: release
>
> Description:
>        Cannot redirect into an array from multiline variable
>
> Does not work:
> echo "$mydata" | while read line; do myarray+=( "$line" ); done
>

Here the whole *while* statement runs in a subshell. See
http://mywiki.wooledge.org/BashPitfalls#grep_foo_bar_.7C_while_read_-r.3B_do_.28.28count.2B-.2B-.29.29.3B_done.

>
>
> Works:
> while read -r line; do myarray+=( "$line" ); done < <(echo "$mydata")
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]