[Toybox] bash status

Rob Landley rob at landley.net
Fri May 14 01:55:41 PDT 2021


On 5/13/21 12:12 PM, Frank Liu wrote:
> Hi,
> 
> What's the current status on bash support?

Probably around 80% done? Actively working on it: 23 commits to
toys/pending/sh.c since the start of the year.

> The toybox-x86_64 from http://landley.net/toybox/bin/ has "bash", but when I try
> it with a simple script, it failed:

In current git toysh, from the command line:

  $ dummy_method() {
  >   echo "In the Dummy method"
  > }
  $ echo "calling the dummy method"
  calling the dummy method
  $ dummy_method
  In the Dummy method
  $

> Running the script gives below error:
> 
> bash: syntax error: {

It wasn't there in 0.8.4, I added shell function support over the past month or
so, it should be in the next release:

  https://landley.net/notes-2021.html#02-04-2021
  https://landley.net/notes-2021.html#18-04-2021
  https://landley.net/notes-2021.html#26-04-2021
  https://landley.net/notes-2021.html#28-04-2021

I still have a failing test with function argument expansion in for loops, I got
distracted from debugging that by working on job control stuff for a bit
(because adding nommu support for backgrounding a function leads into job
control), but I've (mostly) decided to punt that to next release because job
control's kind of a hairball. I was trying to make backgrounding & and fg/bg and
"jobs" and ctrl-z work by itself... but it ties into tcsetpgrp() and friends,
which means I should write the command history/editing plumbing at the same time
and that puts it out of scope this release. (I should probably add "trap"
support as part of that pass too.)

The next largest missing feature after that is probably $((math)) support.
(Probably gonna use a shunting yard algorithm variant because it's what I did
last time I had to implement a math parser.)

There are still a zillion TODO items in the code, bits of wildcard support
aren't debugged yet (and the +(blah) variants are recognized but the
implementations aren't all filled in). several builtin commands like "declare"
and "set" are missing, lots of the MAYFORK commands need their shell
intergrations implemented (ala the [[ ]] form of test and kill %job support),
I've got magic/readonly/exported/local variables but not integer or upper/lower
case (let alone the two types of arrays)...

Working on it. :)

Rob

P.S. not all my TODOs are in the code. For example, I should change <(blah) from
being a redirect to being a variable expansion since I hit a use case where it
matters: gcc -Wl,T<(echo blah) needs to become -Wl,T/dev/fd/3 or similar, and
despite the path being glued into a longer argument it does actually make sense
in context. For a definition of "sense" that's FSF lunacy, but still...



More information about the Toybox mailing list