I needed to find the source code for the implementation of the false.
I found sources on github and found false.c where false exits with code 255.
So, why does "false; echo $?" return 1 in shell instead of 255?
I think there is a source somewhere that I missed.
code from false.c file:
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
/*
* Exit with a non-zero value as quickly as possible.
*/
int
main(void)
{
_exit(255);
/*NOTREACHED*/
return (0);
}
If bash is your shell,
falseis a builtin -- so you're looking at the wrong source code.See instead the version built into bash itself, in the file
builtins/colon.def:If you want to use your OS vendor's version of
falseinstead of the built-in one, you can do that withcommand falseor/bin/false.