[Toybox] [PATCH] Start replacing get_line() with getline().

Rob Landley rob at landley.net
Tue Jul 23 16:53:23 PDT 2019


On 7/22/19 6:28 PM, enh wrote:
> On Mon, Jul 22, 2019 at 2:44 PM Rob Landley <rob at landley.net> wrote:
>>
>> On 7/22/19 10:17 AM, enh via Toybox wrote:
>>> thoughts?

Oh, I remember why I did get_line() that way initially:

$ echo one two three four five | while read -d ' ' a; do echo 1$a; cat <(read -d
' ' a; echo 2$a); done
1one
2two
1three
2four
$

I.E. what happens when two different processes read from stdin in some sort of
defined sequence: the stdio FILE * input buffer doesn't get inherited and can't
be pushed back into pipes.

Don't ask me why bash didn't output "1five". If you add a ' ' at the end of the
echo you get:

1one
2two
1three
2four
1five
2

So I did "slow but controllable" and put "speed this up" on my todo list later.
Then getline() was added to posix 2008 and it being standardized and faster
outweighed the behavior being correct...

Rob



More information about the Toybox mailing list