How to use "read" in Busybox v1.1.1 ?

Michael Conrad mconrad at intellitree.com
Wed May 13 17:00:19 UTC 2015


On 5/13/2015 11:30 AM, Jody Bruchon wrote:
> On 05/13/2015 11:27 AM, Michael Conrad wrote:
>> My bash behaves like busybox. As far as I know it has never been
>> possible to "read $foo" and get the value placed into $foo (unless
>> $foo=foo)
> I confirmed that bash on one of my servers does allow use of 'read 
> $foo' instead of 'read foo'. It seems like a bad idea though; if a 
> POSIX sh-compatible script sets foo=bar and goes 'read $foo' to 
> effectively perform a 'read bar' then bash will break it.
>

The oldest bash I have is
    GNU bash, version 4.2.53(1)-release (i386-pc-linux-gnu)
    Copyright (C) 2011 Free Software Foundation, Inc.
and doesn't work there either.

I'm curious, what happens in your version of bash if you use read in a loop?

while read $foo; do
   echo $foo;
done

Does it start writing to an unintended variable on the second iteration?



More information about the busybox mailing list