[Toybox] Would someone please explain what bash is doing here?

enh enh at google.com
Fri Mar 6 08:08:23 PST 2020


you could try chet ramey or the bash mailing list... he joins in a lot
of the shell discussions on the POSIX mailing list.

On Fri, Mar 6, 2020 at 4:03 AM Rob Landley <rob at landley.net> wrote:
>
> Is it just me, or is bash's unquoted $@ processing with a non-whitespace IFS
> only retaining blank arguments when they're followed by another argument (even
> if that one is blank)?
>
> $ func() { bash -c 'IFS=x; for i in $@; do echo =$i=; done' blah "$@"; }
> $ func one "" two
> =one=
> ==
> =two=
> $ func one ""
> =one=
> $ func "" two
> ==
> =two=
> $ func "" ""
> ==
>
> (I mean, it could be worse. Busybox ash is _never_ retaining zero length
> arguments here. But I'm trying to figure out what logic bash is using, and not
> finding a coherent design idea. Is this a bug, or did they mean to do it? If
> they meant it, _why_?)
>
> Rob
>
> P.S. I dug up bash 2.05b and at least it's been CONSISTENT for 18 years, so I
> guess that's something? But... why?
>
> P.P.S. As far as I can tell, $@ and $* behave the same unquoted, and that's the
> codepath I'm currently trying to implement.
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net


More information about the Toybox mailing list