Toybox in OpenWrt

Hi, I sent the below to the developers list ( - but email barfed with a "Recipient address rejected" - so copying here to the forum!

Hi All,

Idle though here, should we think about the release after 21.02 of changing the shell from busybox to toybox?:

Toybox is Rob Landley single executable with multiple linux commands, so same concept as busybox, but different licensing (BSD0) so is used in android. Anyway toybox gets closer to version 1.0, with the shell development being the major obstacle. The shell is designed to have most of the functionality of bash, which for openwrt would make script writing easier - with ash I pretty much need to test each line as I write it, to check it works in ash. A bash like shell would make life easier.

Toybox is also being updated to more recent net libraries - so makes sense for a router OS to stay current and modern.

Anyway this post is mainly to see peoples thoughts, is there any traction for this idea out in the community?

When 21.02 comes out, I'll probably look at doing a package of toybox, so I can drop it in - then look at converting the various scripts to work in toybox.



Is there a justification beyond being new and just about hitting v1.0?

busybox is a rather core component of OpenWrt, more so than for other/ bigger distributions, to the extent that OpenWrt regularly needs to extend certain applets. Replacing this with anything else would be a rather large endeavour, which -even with a quite feature complete distribution- would probably require quite some back- and forth with upstream, as issues arise and missing features are identified. Adding this optionally, in a drop in fashion sounds like a recipe for disaster.

The licensing difference is rather immaterial to OpenWrt (both are FLOSS and there are enough other GPL licensed core components that this wouldn't make a difference to OpenWrt as a whole anyways). And the shell supporting more bashisms than busybox-ash isn't really an advantage, especially since major distributions pushed for POSIXly correct shell scripting (to facilitate faster boot times by using smaller/ faster non-interactive shells as /bin/sh, e.g. dash - which is much stricter than busybox-ash) 15 years ago, condemning bashisms in the ecosystem at large.

Main difference between busybox and toybox is toybox is under very rapid development, and its shell is designed to be a bash clone.

Yes I agree that changing to toybox would be a major change in openwrt (so like changing uClibc to musl) - this to my mind is whay it should only be considered, just after a major release is forked. This way one gets the whole development cycle to make whatever changes needed.

toybox as a whole is compliant with an old version of POSIX, but in its shell extends to beyond POSIX. Is ash POSIX compatible? I find coding in it very hard, but I may well have picked up on bash habits in last 20 years - to my mind though ash has alot less functionality than the bourne shell.

Interesting question though - although Rob Lanley is flat out on getting toybox out these days - do half wonder if post 1.0 if look at last doing a more minimal shell, based on current code - but with things like rational variable expansion.

Personally I would have no interest to switch to toybox or to invest any time converting to it. I'd also be very reluctant to change the default shell in OpenWrt. There's so many 3rd party scripts out there which are not under our control that the likeliness for unintended regressions is rather high.

Furthermore, I personally don't really want to rely on a core component where the feature scope and development is heavily influenced by Google. Sure, the license is permissive, but if at one point the development moves into a direction not aligning with our requirements, we'd be forced to stick to an old release or to maintain it ourselves, which we (I presume) don't have the capacity or desire to.

Personally I do like the conservativeness of Busybox development and Denys' slowness to merge patches does not justify switching to a replacement for me. Whenever we needed things to end up in Busybox, we managed to get them merged there.

Switching from a limited scripting language (ash) to a slightly less limited scripting language (bash-like) also does not seem to be enough of a justification for me.

1 Like

Good point on google, yes in toybox something like 50% of patches come from google, as they use it on android. Yes it means google involvement, but also means people working on toybox, and thats part of what means its making fast progress.

Its probably more than just the shell, that makes toybox interesting, e.g. the network programs being converted to use netlink. Not sure how far toybox is through doing this, and actually don't know what busy box does.