[Toybox] [landley/toybox] bunzip2/gunzip don't properly handle .tbz/.tgz files (Issue #465)

Rob Landley rob at landley.net
Thu Oct 30 12:13:48 PDT 2025


> The only remaining issues are with bunzip2:
> 
> ```plain
> toybox bunzip2 FILE.tbz  --> bunzip2: FILE.tbz: Invalid argument
> toybox bunzip2 FILE.tbz2 --> FILE.tbz2
> ```

Adding "tbz" to the suffix list is easy enough, but... this isn't so 
much "bugs" as "lack of specification for what the behavior should _be_.

Hmmm... toybox's bunzip2 with an unrecognized extension is complaining 
but did actually decompress it, it just can't rename it. So it did what 
was asked (the input had a bunzip2 signature and successfully 
decompressed without error), it just didn't know how to rename it and 
instead replaced the original file.

When I ran debian's bzip2 on the result _again_ it says "Input file 
toys.h.tbz already has the .tbz suffix." and won't re-compress it even 
though it's ascii test.

I don't have a bunzip2.test in part because things like "output going to 
a terminal" aren't really easy to test. I _really_ need to make a pty 
wrapper command, maybe toys/examples/testpty.c and have "make tests" add 
a KCONFIG_ALLCONFIG=<(echo CONFIG_TESTPTY=y) or something and then the 
test can "which -q testpty" to skip the tests.

Part of the reason I hadn't done this before was android isn't using my 
build infrastructure so their tests wouldn't have the testpty command, 
but ever since they decided "the phone should be its own independent 
system that underprivileged people can use to become first class 
developers" is the same as "people with a laptop can use adb but 
everyone else must be locked out" and then donated millions to the 
Epstein Ballroom fund to knock down the east wing after installing 
project 2025 content scanners on everyone's phone (and of course haven't 
pushed _their_ toybox tree anywhere public I can find for half a 
year)... Ahem. Tangent.

Ah, "which" hasn't got a -q because "do we have this command" apparently 
did not occur to gnu as a valid use case. And the bash builtin "command" 
hasn't got one either, although -v changes the output to be 0 or 1 
(instead of 127 if not found otherwise the command's output when run) 
but you still have to redirect the output (awkward to do in "skipnot").

I guess I could just add a "whichq" shell function alongside skipnot and 
toyonly. The test suite needs better documentation in general, but all 
this is under my "root tests" todo item: get toysh to run the tests 
under mkroot, then implement root tests and kernel module tests and tty 
tests and so on.

Kinda lost enthusiasm recently...

Rob

P.S. vim's autodetection of compressed file formats and silently 
handling them was NOT asked for (I want a text editor, not a word 
processor, be less magic please) and made debugging this harder. (DO NOT 
HELP IN THE KITCHEN. When I pull out a knife and get the "singing sword" 
from Roger Rabbit you have NOT IMPROVED matters. Stoppit.)


More information about the Toybox mailing list