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: Ted Okuzumi
Subject: Re: Severe Bash Bug with Arrays
Date: Wed, 25 Apr 2012 10:36:53 -0700

Please note that if I use a different command in the while loop it works.

So instead of
echo "$mydata" | while read -r line; do myarray+=( "$line" ); done

if I say:
echo "$mydata" | while read -r line; do echo "$line" ; done

Then it works.  To pipe output into a while statement works, normally,
however it fails when the array+=( )  is used.  It doesn't fail on other
commands that I've seen.

This is why I am saying it is definitely a bug.  Do you not agree?

Thanks,
Ted

On Tue, Apr 24, 2012 at 10:23 PM, Clark Wang <clark.wang@oracle.com> wrote:

> 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]