5 ms·
I do like that /bin/true can actually fail and return false, which technically makes a "Not /bin/false" invocation more resilient: https://github.com/coreutils/
by MenhirMike 3y ago
I do like that /bin/true can actually fail and return false, which technically makes a "Not /bin/false" invocation more resilient: https://github.com/coreutils/coreutils/blob/master/src/true.c#L67 https://github.com/coreutils/coreutils/blob/master/src/true.... (and yes, I know it's the most unlikely thing, I just found it funny)
- yjftsjthsd-h 3y agoOnly if run with options, right? It looks like just running `true` is unaffected unless the comment is misleading me.
- patal 3y agoYeah, I don't see it either. If being run without --help or --version, true can only ever return EXIT_SUCCESS. However, I find it interesting that true and false use the very same implementation.
- somat 3y agoThe other interesting thing about the true command is how much more complicated it got then it needed to be. first an exercise touch mytrue chmod u+x mytrue ./mytrue echo "error code for mytrue is $?" This is literally how true started life. yes it is very zen. The first offense was legal. All code had to have a copyright disclaimer. even an empty file? Yes. so now it was a file with a copyright disclaimer and nothing else. And the koan-like question comes to mind is "Can you copyright nothing?" well AT&T sure tried. Then somebody said our programs should be well defined and not depend on a fluke of unix, which at this point was probably a good idea. So true finally had code. It was "exit 0" Then somebody said we should write our system utilities in C instead of shell so it runs faster. openbsd still has a good example of how this would look. http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/true/true.c?rev=1.1&content-type=text/plain http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.... At some point gnu bureaucracy got involved and said all programs must support the '-h' flag. so that got added, then they said all programs must support locale so that got added. now days gnu true is an astonishing 80 lines long. https://github.com/coreutils/coreutils/blob/master/src/true.c https://github.com/coreutils/coreutils/blob/master/src/true.... Which is fine I guess, but that is a lot of code for a program that by definition "Does nothing, successfully" http://trillian.mit.edu/~jc/humor/ATT_Copyright_true.html http://trillian.mit.edu/~jc/humor/ATT_Copyright_true.html