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

Rob Landley rob at landley.net
Mon Mar 9 20:16:56 PDT 2020


On 3/9/20 5:29 PM, enh wrote:
> On Mon, Mar 9, 2020 at 1:05 PM Rob Landley <rob at landley.net> wrote:
>> I want to convince Android to create a "posix container" based on "mkroot plus
>> stuff" within which AOSP image builds can run to completion on arbitrary android
>> devices, but first I need to get Linux From Scratch building under that again as
>> a proof of ocncept. (In Aboriginal Linux I had LFS building automatically on
>> multiple architectures starting from nothing but linux, busybox, uClibc, gcc,
>> binutils, make, and bash, the automation infrastructure was
>> http://landley.net/aboriginal/control-images/. Ideally I can get that down to 4
>> packages if I finish the toybox roadmap (linux, qcc, musl, and toybox), but the
>> nearer-term goal is getting the android NDK to act as a full system build
>> compiler. (Elliott is the Android base OS layer maintainer, he doesn't maintain
>> the NDK
> 
> well, one of the big improvements the guy who does maintain the NDK
> has made in recent years is that the NDK is no longer a forked set of
> headers (with a copy per API level) --- it's a direct copy of the OS
> headers at the time the NDK is built, and any API level differences
> are reflected directly in the OS headers.

The NDK has made great progress, I've just been stretched _way_ too thin to keep
all the plates I want spinning. :(

I'm currently trying to get a toybox release out ASAP (with the shell maybe not
promoted, but at least in a reasonable state) because I fly back to Tokyo before
too much longer to disappear into the j-core.org mines for some number of
months. (I have a tokyo residence card now. I need to get an apartment there
when I get back.)

>> No, I don't care what dash does. It can go hang.
> 
> certainly in terms of shell scripts i've seen where people have asked
> me "why doesn't this work on Android?", the answer has only ever been
> "because that's a bash extension that's not in mksh".
> 
> asking for more bash features is a fairly common experience -- even
> stuff like exponentiation in $(()) that you wouldn't necessarily
> imagine would see much use

Oh I imagine just about everything sees use.

  $ echo $((2**3))
  8
  $ echo $((2**3.4))
  bash: 2**3.4: syntax error: invalid arithmetic operator (error token is ".4")

Sigh. Well at least it's still the _easy_ exponentiation.

I have not yet opened the $(( )) and for ((;;)) cans of worms yet. I eventually
figured out that (( )) on the command line is because you can assign values to
variables, so you can do:

  $ ((x++)); echo $x
  1

And yes, I've pondered using "double" for the ((math)) plumbing. I am not crazy
enough to have _committed_ to it yet, but it's a thing I have missed _not_ being
there before. (I keep having to fire up python instead.) And the last time I
implemented this plumbing (in java), it was floating point. (SO much code to
preserve "number of significant digits in the fractional part" for printing...)

> -- but i can't even imagine a world in
> which someone comes to me asking for more *dash* compatibility :-)

It was a mistake Ubuntu made and pushed "upstream" into debian. The goal was
never "remove everything that's not in posix", that was just a side effect. But
there's a lot of cognitive dissonance about "doing it didn't accomplish anything
ELSE, so that must be why it was done, and must therefore be a good and useful
goal to have intended"...

If I get toybox where I want it to be, then there would be two compatible
implementations of _bash_. At which point we can technically submit an RFC to
the IETF for it, ala gzip. :)

>>> Chet
>>
>> Rob

Rob


More information about the Toybox mailing list