$ gcc pear.c
$ ./a.out | sed -e '1i#!/bin/bash' -e 's/.*/test & ; echo $?/' > blah.sh
$ chmod +x blah.sh
$ ./blah.sh | wc
So... tests for test. With 5376 true/false results. Probably overkill? (This
tests parentheses vs -a and -o prioritization for all combinations of 3 -a/-o
tests and 4 pairs of parentheses. Dunno about "right" but I can check "matches
bash"...
Rob
#include <stdio.h>
/* Emit all possible combinations of ( x ) -y ( x ) -y ( x ) -y ( x )
where X is true/false, -y is and/or, and parentheses present/absent. */
// 15 bits: top 4 are (, next 4 ), next 4 x, next 3 y
int main(int argc, char *argv[]) {
int i, j, k;
// Iterate through 15 bits of possibilities
for (i=0; i<32768; i++) {
// filter out illegal ( ) seqeuences: never more ) than (, one left over.
for (j=k=0; j<4; j++) {
if (i&(1<<(11+j))) k++;
if (i&(1<<(7+j))) k--;
if (k<0) break;
}
if (k) continue;
for (j=0; j<4; j++) {
if (j) printf(" -%c ", "ao"[!(i&(1<<(j-1)))]);
printf("%s %s %s", (i&(1<<(11+j))) ? "\\(" : "",
(i&(1<<(3+j))) ? "\"\"" : "x",
(i&(1<<(7+j))) ? "\\)" : "");
}
printf("\n");
}
}
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net