Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!linus!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: In sh, is '[' a portable synonym for 'test'? Message-ID: <2887@sun.uucp> Date: Sat, 12-Oct-85 19:58:32 EDT Article-I.D.: sun.2887 Posted: Sat Oct 12 19:58:32 1985 Date-Received: Tue, 15-Oct-85 07:18:35 EDT References: <482@phri.UUCP> Distribution: net Organization: Sun Microsystems, Inc. Lines: 15 > > On my 4.2bsd system, the following do the same thing in sh because > /bin/[ is a link to /bin/test. ... Is the "[]" form safe to use if you want > to make something portable? My Sys5 manual (January 1983) notes the two > forms but mentions that the second is not recognized on all systems. Does > anybody know on what systems it will fail? V7 systems where /bin/[ isn't a link to /bin/test. Any V7 or post-V7 system can be made to support "if [ ]" as equivalent to "if test ", but the S5 manual properly warns you that not all systems have been made to support it. If you want to make something portable, and you don't think you can convince every recipient of the program to make that link, you're best off not using "[ ... ]". GUy Harris