-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, Aug 17, 2018 at 06:46:54PM +1000, Zenaan Harkness wrote: > 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
Note that after false, test $? && echo ok || echo error $? expands (after variable expansion) to test 0 && echo ok || echo error 0 ... which ends up saying "ok", because test 0 succeeds :-) The only one-arg test which fails is test "". Yes, a bit unexpected, due to (a) the shell's evaluation model and (b) test's behaviour. To defend bash's documenters (a bit) its help system provides you with tiny snippets of information (try "help false"). Cheers - -- tomás -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlt2lKAACgkQBcgs9XrR2kYBJwCfePdOAVb3gxz9pcTqxWofLKNM LcMAn2nZXDOwuhoxmbE+0wzEVX/oWceS =7I3U -----END PGP SIGNATURE-----