[Toybox] test.c patches on GitHub

Rob Landley rob at landley.net
Wed Sep 5 11:21:29 PDT 2018


On 08/31/2018 05:55 PM, Kevin Spiteri wrote:
> Hi,
> 
> There are three patches on GitHub (PRs #47, #100, #102) that fix some
> significant issues with test.c. Is that the right place to submit?

It's an acceptable place. I've seen them. I just need to do some structural
cleanup on this command. (That's why it's in pending.)

For example, it's modifying toys.optc and toys.optargs, and I try not to do that
from within commands. (I have a vague idea I might want to make an optional
version of TOYFLAG_NOFORK someday so some commands have the option to run in the
shell's process context, but can also be run standalone. Doing that means
generic code would have to clean up after it, and losing track of what your
arguments are is a bad idea there. In this case it wasn't washed through
lib/args so didn't allocate more arguments, but it's the principle of the thing.)

Also, why do we have the stridx() call when we could just compare against the
'c' char value in the if/else staircase and then have the last else be the
unrecognized error? Maintaining the same data in two places (that have to stay
in sync) is bad, and marshalling data to yourself is wasted effort...

Ah, I remember what the big timesink for this one is: [ TEST -a TEST -o TEST -a
TEST ] needs a loop, which is reminiscent of the logic in "find" which meant I
wanted to look at the find code to see if anything there was worth factoring out
into lib so it could be shared.

I'll take this as an expression of interest in the test command and see if I can
get it promoted out of
https://github.com/landley/toybox/tree/master/toys/pending/README this release.

Thanks,

Rob



More information about the Toybox mailing list