Date: Tue, 4 Jun 1996 09:35:38 -0700 From: "Jin Guojun[ITG]" <jin@george.lbl.gov> To: wosch@cs.tu-berlin.de Cc: bugs@freebsd.org, problem@bsdi.com Subject: Re: test(1) (was sh bug) Message-ID: <199606041635.JAA05219@george.lbl.gov>
next in thread | raw e-mail | index | archive | help
} 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-/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606041635.JAA05219>