Subject: bin/35184: ksh does not handle '-o' or '-a' conditionals correctly if comparing strings containing hyphens
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <john.horne@plymouth.ac.uk>
List: netbsd-bugs
Date: 12/04/2006 14:00:01
>Number: 35184
>Category: bin
>Synopsis: ksh does not handle '-o' or '-a' conditionals correctly if comparing strings containing hyphens
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Dec 04 14:00:01 +0000 2006
>Originator: John Horne
>Release: 3.1
>Organization:
University of Plymouth
>Environment:
NetBSD localhost. 3.1 NetBSD 3.1 (GENERIC) #0: Tue Oct 31 04:27:07 UTC 2006 builds@b0.netbsd.org:/home/builds/ab/netbsd-3-1-RELEASE/i386/200610302053Z-obj/home/builds/ab/netbsd-3-1-RELEASE/src/sys/arch/i386/compile/GENERIC i386
>Description:
Under ksh the following conditional test fails:
$ test "-n" = "-n" -o "-e" = "-e" && echo ok
ksh: test: -n: unexpected operator/operand
This fails if a '-a' is used instead of the '-o' as well.
Using '==' instead of '=' also fails. Use of strings other than
'-n' (or something that may be recognised) works:
$ test "-hjhj" = "-hjhj" -o "-yuyu" = "-yuyu" && echo ok
ok
The first test works fine under bash.
>How-To-Repeat:
1) Type in:
/bin/ksh
2) Type in:
test "-n" = "-n" -o "-e" = "-e" && echo ok
>Fix: