Very nice; tried it and got a 129 byte working true command.
Now I have to understand what's in the 28896 bytes of the true command that comes with the distro I have here.
The real kicker is GNU false: http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/fals...
A sort of "reversed polarity", if you will.
int
main (int argc, char **argv)
{
return EXIT_SUCCESS;
}
plus all the stuff required to handle --version and --help.But even compiling just that results in 60 kB on my system. What's in those other kilobytes, indeed!
$ type true
true is a shell builtinThen if you open it in a hex editor (or use od -x), I'll bet you'll see pages and pages of zeroes, which are used for aligning it appropriately in RAM when it loads.
At least, those are all things that work on some systems, can't be sure about yours.
$ gcc tiny.c -O3 -o tiny; wc -c tiny
8456 tiny
$ strip tiny; wc -c tiny
6224 tiny
$ sstrip tiny; wc -c tiny
4140 tiny
[1] http://www.muppetlabs.com/~breadbox/software/elfkickers.html /* Note true(1) will return EXIT_FAILURE in the edge case where writes fail with GNU specific options. */
If you can't program a bug free true(1), please stop with whatever you think you are doing.