From owner-freebsd-bugs Tue Jun 4 05:36:43 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id FAA09524 for bugs-outgoing; Tue, 4 Jun 1996 05:36:43 -0700 (PDT) Received: from mail.cs.tu-berlin.de (root@mail.cs.tu-berlin.de [130.149.17.13]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id FAA09519 for ; Tue, 4 Jun 1996 05:36:39 -0700 (PDT) Received: from campa.panke.de (anonymous235.ppp.cs.tu-berlin.de [130.149.17.235]) by mail.cs.tu-berlin.de (8.6.12/8.6.12) with ESMTP id OAA15113; Tue, 4 Jun 1996 14:22:12 +0200 Received: (from wosch@localhost) by campa.panke.de (8.6.12/8.6.12) id OAA00439; Tue, 4 Jun 1996 14:09:22 +0200 Date: Tue, 4 Jun 1996 14:09:22 +0200 From: Wolfram Schneider Message-Id: <199606041209.OAA00439@campa.panke.de> To: "Jin Guojun[ITG]" Cc: bugs@freebsd.org, problem@bsdi.com Subject: test(1) (was sh bug) In-Reply-To: <199606031939.MAA26616@george.lbl.gov> References: <199606031939.MAA26616@george.lbl.gov> Reply-to: Wolfram Schneider MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Jin Guojun[ITG writes: >The sh in BSD does not take "-" as the argument in if statement if the >statement has more than one comparsions. >The following line are generating errors: > >if [ "$1 = "-h" -o "$1" = "-help" ]; then ^ you forgot a quote, but this is not the problem >ERROR: >+ [ -h = -h -o -h = -help ] >[: syntax error: Undefined error: 0 > > >but, it works in a single argument if statement: > >if [ "$1 = "-h" ]; then > ... >fi > >Would some one please fix it? workaround: if [ X"$1" = X"-h" -o "$1" = "-help" ]; then ^ ^ or use a case statement: case "$1" in -h|-help) echo usage;; esac Note: this is a test(1) bug, not a bug in sh(1). test (alias `[') is *not* a sh builtin. Wolfram