From owner-freebsd-bugs Tue Jun 4 09:35:56 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id JAA23793 for bugs-outgoing; Tue, 4 Jun 1996 09:35:56 -0700 (PDT) Received: from george.lbl.gov (george.lbl.gov [128.3.196.93]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id JAA23788 for ; Tue, 4 Jun 1996 09:35:54 -0700 (PDT) Received: (jin@localhost) by george.lbl.gov (8.6.10/8.6.5) id JAA05219; Tue, 4 Jun 1996 09:35:38 -0700 Date: Tue, 4 Jun 1996 09:35:38 -0700 From: "Jin Guojun[ITG]" Message-Id: <199606041635.JAA05219@george.lbl.gov> To: wosch@cs.tu-berlin.de Subject: Re: test(1) (was sh bug) Cc: bugs@freebsd.org, problem@bsdi.com 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 This is a typo when doing copy and paste. } >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 Good, I think it is easy to fix when it is really needed since this is a test(1) bug. There is no problem to get around this situation. If I remember correctly, I only saw this problem under old Ultrix a quite ago. Almost all workstation systems accept "-XXX" in test(1) now, including SOLARIS/IRIX -- POSIX compliance. So, I just wonder if BSD should do the samething and make it better. Thank you for the information, /-------------- Jin Guojun ------------ v ---- Internet: g_jin@lbl.gov ----\ | Imaging & Distributed Computing | Usenet: ucbvax!g_jin@lbl.gov | | Lawrence Berkeley Laboratory | Bitnet: -- | | 50B-2239, Berkeley, CA 94720 - jin%george.lbl.gov@Csa3.LBL.Gov | \--Ph#:(510) 486-7531 + Fax: 486-6363 --^--http://www-itg.lbl.gov/ITG.html-/