Technical article 109532

ksh -c "[[ bbb > aaa ]]" gives error "ksh: bbb: bad number" under OpenServer 5.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4

Written · Last revised

Problem

The ksh greater-than string comparison:
[[ string1 > string2 ]]

doesn't work as documented, returning an error ("#" indicates the command line prompt):

# ksh -c "[[ bbb > aaa ]] && echo true"
ksh: bbb: bad number
#

Solution

This problem has been reported to SCO Engineering and is scheduled to be addressed in a future release of SCO OpenServer 5.

A simple workaround is to reverse the order of the string arguments, and use the corresponding less-than string comparison:

[[ string2 < string1 ]]

See also

manual page ksh(C)

From the Xinuos technical article database, record 109532. Reproduced with permission. The original is at www.sco.com/ta/109532, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.