On Tue, May 18, 2010 at 1:03 PM, Cristian Ionescu-Idbohrn
<cristian.ionescu-idbo...@axis.com> wrote:
>> > > wrong. It eats leading and trailing whitespace.
>> >
>> > I cannot find anything in the opengroup page you earlier referred to:
>> >
>> >         http://www.opengroup.org/onlinepubs/009695399/utilities/read.html
>> >
>> > saying explicitely "whitespace must me preserved".
>>
>> Yes, that's what Denys is saying.  The rewrite is NOT equivalent to the
>> bash version, because the bash version preserves leading/trailing
>> whitespace, and the rewrite does not.
>
> And that's what I'm also saying :)  Let me rephrase.
> Expecting 'read' to preserve leading and trailing whitespace is not
> POSIX.  It's a bashism.  Don't do that.  Which makes the rewrite
> correct, IMO.

Gosh. Rewrite should preserve the *functionality*, that is,
it should *read entire line without mangling it* (ok,
sans NUL bytes...)
The proposed patch didn't do it, therefore *it is incorrect*.

If standard shell can't do it, it does not mean I must sacrifice
functionality. It means that standard shell sucks.

If standard shell can do it, but requires extensive ugly hacks
to achieve it, it means that standard shell sucks
(just not as much as in the case it can't do it at all).

For the record: standard shell can do it, with somewhat ugly hack.
I bet a lot of people will not come up with this hack though...
they will likely try to save/restore IFS around read,
which is butt-ugly:

while sv="$IFS"; IFS=''; read -r line; IFS="$sv"; do...

Gaack...

-- 
vda
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to