[Toybox] [PATCH] toysh: [ isn't a bultin in single command binaries while test and [[ are. Also shut up arch by replacing egrep with grep -E

Oliver Webb aquahobbyist at proton.me
Sat Feb 10 19:22:25 PST 2024

Hello, I was benchmarking toysh against shells like dash and bash by calling the [ command
1,000,000 times, assuming it was a builtin on toysh.

dash and bash can do this in less than 10 seconds, while toysh takes 16.5 _minutes_. After 
some fiddling with strace, I noticed it was forking off the [ command...
which is declared with TOYFLAG_MAYFORK (to prevent this exact issue)

The problem is in scripts/single.sh, which while building the toysh searches for MAYFORK in command declarations
to declare as dependencies... but only ones declared with the NEWTOY() macro,
which [ (aka USE_TEST_GLUE) isn't (The only OLDTOY() with TOYFLAG_MAYFORK too).

This patch fixes that, so that [ is automatically available as a buitin while building a single command
binary of the shell.

Also, at least on arch linux, egrep has been replaced by a shell script that warns the user that
egrep is deprecated, then calls grep -E. To get rid of these warnings, I replaced egrep with grep -E in this patch

-   Oliver Webb <aquahobbyist at proton.me>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-replace-egrep-with-grep-E-to-shut-up-arch-linux-Scan.patch
Type: text/x-patch
Size: 2261 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20240211/52ade08c/attachment.bin>

More information about the Toybox mailing list