On Saturday 15 May 2010 19:57, Cristian Ionescu-Idbohrn wrote:
> 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.

But bash is de-facto standard Linux shell. Not ksh or zsh.
Therefore, it makes sense to match bash behavior
where it does not require major coding.

Sure, I can stop using "read" without parameter.
But this does not affect many other shell scripts out there -
hundreds or thousands of them use this construct.

If, instead, we patch dash to understand "read" without parameter
(which can't be too hard), all those scripts start working.

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

Yes.
 
> Is this an input line too?
> 
>       bash$ echo "  foo  b\ar  " | { read REPLY; echo "[$REPLY]"; }
>       [foo  bar]

Yes.

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

Bug.

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

Reply via email to