#735042 [bash] 0 is null (misleading test documentation)

Package:
bash
Source:
bash
Description:
GNU Bourne Again SHell
Submitter:
Filipus Klutiero
Date:
2014-06-22 22:30:07 UTC
Severity:
minor
#735042#5
Date:
2014-01-12 05:23:22 UTC
From:
To:
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.

#735042#8
Date:
2014-06-20 18:40:15 UTC
From:
To:
[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?

#735042#13
Date:
2014-06-21 21:05:50 UTC
From:
To:
 > [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.

#735042#18
Date:
2014-06-22 22:26:33 UTC
From:
To:
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.