strings not comparable with "<" or ">" as described in man page

Bug #718396 reported by afoglia
6
This bug affects 1 person
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
            (false). If there is no expression, test also returns 1 (false).

            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
                          value of their characters.

            s1 > s2 True if string s1 comes after s2 based on the ASCII
                          value of their characters.

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.

Revision history for this message
Jilles Tjoelker (jilles) wrote :

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

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.