On Sat, 15 May 2010, Denys Vlasenko wrote:

> On Friday 14 May 2010 21:44, Cristian Ionescu-Idbohrn wrote:
> > On Fri, 14 May 2010, Denys Vlasenko wrote:
> >
> > > I did discover a lot of interesting details about shells
> > > while hacking on them. One is that bare "read"
> > > is NOT the same thing as "read REPLY"! Look at this:
> > >
> > > $ echo "  foo  b\ar  " | { read -r; echo "[$REPLY]"; }
> > > [  foo  b\ar  ]
> >
> > $ dash -c 'echo "  foo  b\ar  " | { read -r; echo "[$REPLY]"; }'
> > read: 1: arg count
> > []
>
> They are not bash compat :)

Pick any one shell as _the_ reference shell and compare it with all other
major shells.  The in"compat"ibilities (bash or not bash) will be
noticable.

> > > $ echo "  foo  b\ar  " | { read -r REPLY; echo "[$REPLY]"; }
> > > [foo  b\ar]
> >
> > $ dash -c 'echo "  foo  b\ar  " | { read -r REPLY; echo "[$REPLY]"; }'
> > [foo  br]
> >
> > (with a bell ringing)
>
> Bug per http://www.opengroup.org/onlinepubs/009695399/utilities/read.html

Yes.  And there's still a lot of room for interpretation:

-r
    Do not treat a backslash character in any special way. Consider each
    backslash to be part of the input line.

But what is an input line?

Is this an input line?

        bash$ read -r REPLY <<EOF
        >   foo  b\ar
        > EOF
        bash$ echo "[$REPLY]"
        [foo  b\ar]

Is this an input line too?

        bash$ echo "  foo  b\ar  " | { read REPLY; echo "[$REPLY]"; }
        [foo  bar]

Busybox ash imitating bash:

        ash$ read -r REPLY <<EOF
        >     foo  b\ar
        > EOF
        ash$ echo "[$REPLY]"
        [foo  b\ar]

        ash$ echo "  foo  b\ar  " | { read REPLY; echo "[$REPLY]"; }
        [foo  bar]

What about this?

        dash$ read -r REPLY <<EOF
        >    foo  b\ar
        > EOF
        dash$ echo "[$REPLY]"
        [foo  br]

        dash$ echo "  foo  b\ar  " | { read REPLY; echo "[$REPLY]"; }
        [foo  br]

(rings the bell in both cases)


But I thought we were discussing the bash REPLY obfuscatin, did we not?


Cheers,

-- 
Cristian
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to