Add `false` option
Since this is a port of the unix utility true, I feel it is important to provide a false option. Quoting from the man page for GNU true:
Note, however, that it is possible to cause ‘true’ to exit with
nonzero status: with the ‘--help’ or ‘--version’ option, and with
standard output already closed or redirected to a file that evokes an
I/O error. For example, using a Bourne-compatible shell:
$ ./true --version >&-
./true: write error: Bad file number
$ ./true --version > /dev/full
./true: write error: No space left on device
Clearly we need to provide equivalent functionality in the npm module.
I feel it is important to provide a false option.
It's too complicated. Let's respect the single responsibility principle.
Apologies for coming onto this thread so late.
It's worth noting that true does indeed have a complementary false module. (Just as with the actual Unix false utility that exists.)
These methods of evoking a non-zero exit code from true seem somewhat hacky and not necessarily intended by the author of the Unix true. It's not exactly a false 'option.' Are there any ideas for how this would work with our Node port here?
Still not solved?
This is 2021.
Guys, i solve the issue by creating another function
const random = require('random')
function aJavaScriptPortOfTheUnixUtilityTrueReturnsTheBooleanValueFalseButWithTwist(){
return random.int(0, 100) < 98 ? !aJavaScriptPortOfTheUnixUtilityTrueReturnsTheBooleanValueTrue() : aJavaScriptPortOfTheUnixUtilityTrueReturnsTheBooleanValueTrue();
}
While this is an interesting approach, I am beginning to think the ideal way to handle this is with quantum states.
For false we should make separate package.
As I just said: https://github.com/mde/true/issues/15#issuecomment-390226854
Probably worth wrapping this thread up. Good points for considering, given how critical this library truly is.