strings not comparable with "<" or ">" as described in man page
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dash (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: dash
This is probably more a bug in the man page, than in the program, but the man page for dash states:
test expression
[ expression ]
The test utility evaluates the expression and, if it evaluates to
true, returns a zero (true) exit status; otherwise it returns 1
All operators and flags are separate arguments to the test util‐
ity.
The following primaries are used to construct expression:
[...]
s1 < s2 True if string s1 comes before s2 based on the ASCII
s1 > s2 True if string s1 comes after s2 based on the ASCII
But the following comparison doesn't work:
$ dash
$ [ "2.6" < "2.6" ]
dash: cannot open 2.6: No such file
Since the greater and less than comparisons are probably not supposed to be in dash, they shouldn't be in the man pages. Or if they are supposed to be posix extensions in dash, they are not working properly. Either way, the man pages and the program should agree.
You need to quote the operators to distinguish them from redirections. It may be appropriate to mention this in the man page.
For example:
$ [ 2.6 "<" 2.7 ]; echo $?
0
$ [ 2.6 ">" 2.7 ]; echo $?
1