According to the part on test of bash's manpage: $ test 0; echo $? 0 Given 1 argument, bash interprets the expression as -n STRING. In string context, "0" is not null, only the empty string is. This is super-upstream, since the language is borrowed from the Base Specifications. I don't see why these rules are necessary. We can only describe behavior up to 3 arguments without resorting to descriptions vague to the point of uselessness.
[I'm not the maintainer of bash.] * Filipus Klutiero <chealer@gmail.com>, 2014-01-12, 00:23: 0 is not null, so the expression is true, so the exit code is 0. What else did you expect?
> [I'm not the maintainer of bash.] [I’m not the one who’s submitted this bug, either.] >> According to the part on test of bash's manpage: >>> 1 argument The expression is true if and only if the argument is >>> not null. >> Yet: $ test 0; echo $? 0 > 0 is not null, so the expression is true, so the exit code is 0. > What else did you expect? Personally, I’d expect for the documentation to read “is not an empty string” in this case instead.
Hi Jakub, The string "0" isn't, but 0 *is* null. I was expecting bash to consider the argument null, the expression false, and test to return 1.