[Toybox] test.c patches on GitHub
Rob Landley
rob at landley.net
Wed Sep 5 15:24:43 PDT 2018
On 09/05/2018 01:21 PM, Rob Landley wrote:
> 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 should copy a bunch of the tests from "find" with regard to ! inside
parentheses meaning something different from ! outside parentheses and such, I
think I wrote about this in old mailing post lists, I should compare the git
commit dates with the web archive and see what i can dig up?
I left myself comments at the end of tests/test.test (what a lovely name);
# test ! = -o a
# test ! \( = -o a \)
# test \( ! = \) -o a
And I dunno what the priority of -a and -o are here:
[ 1 -a "" -a "" -o 1 -a 1 ]
(Let's see, find is doing something like -a chains fast forward on failure, and
-o chains fast forward on success? There's conditional evaluation in find that
doesn't seem to be the case here:
$ test 1 -o 3 -gt walrus
bash: test: walrus: integer expression expected
Confirm ] only matters as last argument when name is [
[ ] = ] ]
And of course gratuitous parentheses:
[ \( 1 -lt 2 \) ]
(So often coming up with the tests to run is the hard part and development's at
most half the work...)
Rob
More information about the Toybox
mailing list