Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

/bin/sh in 3.1 does not fully cope with the test command

From: Stuart Lamble <sjl(at)debtemp.lib.monash.edu.au>
Date: Sun Dec 22 2002 - 19:28:31 EST


Here's what I type to produce the problem:

bash-2.05a$ /bin/sh
$ [ "1.2.3" \< "1.2.4" ]
/bin/sh: [: <: unexpected operator/operand
$ uname -a
OpenBSD carousel 3.1 GENERIC#59 i386
$ /bin/[ "1.2.3" \< "1.2.4" ]
[: ]: unknown operand
$ /bin/[ "1.2.3" \< "1.2.4"
$ echo $?
0

Two bugs, one definite, one which may be a non-bug.

The definite: Either /bin/sh should not recognise "[", and therefore should pass it on to /bin/[, or it should recognise "<" as part of the "[" operator. It's in the documentation from "man test":

     s1 < s2       True if string s1 comes before s2 based on the ASCII value
                   of their characters.

and I'm reasonably sure that it should be part of the POSIX standard.

The possible bug: /bin/[ should need the right square bracket at the end. However, it can easily be argued that since it's being called as /bin/[, rather than just [, I'm stepping outside the bounds of what can reasonably be expected. If it does the right thing when called as "[" instead of "/bin/[", then as far as I'm concerned, that's good enough. (I had to use
/bin/[ to override sh's apparent internal [ operator.)

If any additional information is needed, please don't hesitate to contact me.

Have a Merry Christmas and all that jazz.

Do you need help?X

Regards,

Stuart. Received on Sun Dec 22 19:30:04 2002

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:40 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library