Bash true/false builtings undocumented? "false" not working?
1)
Bash man page largely fails to document the true and false builtins
AFAICT, except for this sentence just under the heading
"^SHELL BUILTIN COMMANDS":
The :, true, false, and test builtins do not accept options and do
not treat -- specially.
But whilst the subsequent list of Bash builtin commands DOES include
entries for ":" (the very first entry) and "test", it appears to fail
to include entries for "true" and for "false".
This would not matter so much except for the following:
2)
Why is executing "false" prior to testing it's output, apparently
differen to executing "false" in a pipeline, e.g.:
$ false
$ test $? && echo ok || echo error $?
ok
$ false blah
$ test $? && echo ok || echo error $?
ok
$ false --
$ test $? && echo ok || echo error $?
ok
$ true
$ test $? && echo ok || echo error $?
ok
$ true && echo ok || echo error $?
ok
$ false && echo ok || echo error $?
error 1
$ false blah && echo ok || echo error $?
error 1
$ false 2 && echo ok || echo error $?
error 1
$ false -- && echo ok || echo error $?
error 1
$ builtin false -- && echo ok || echo error $?
error 1
$ builtin false --
$ test $? && echo ok || echo error $?
ok
$ which false
/bin/false
$ /bin/false
$ test $? && echo ok || echo error $?
ok
The above results are perplexing me, and frustratingly
inconsistent!
For example, "man false" says inter alia:
NAME false - do nothing, unsuccessfully
…
DESCRIPTION Exit with a status code indicating failure.
The descriptions suggests that /bin/false ought work outside of a
pipeline in the same as way inside a pipeline - vhy, is, eet, not,
so?
TIA,
Reply to: