Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site cornell.UUCP
Path: utzoo!utcsri!ubc-vision!uw-beaver!cornell!jqj
From: jqj@cornell.UUCP (J Q Johnson)
Newsgroups: net.unix-wizards
Subject: Re: In sh, is '[' a portable synonym for 'test'?
Message-ID: <130@cornell.UUCP>
Date: Sat, 26-Oct-85 08:09:25 EST
Article-I.D.: cornell.130
Posted: Sat Oct 26 08:09:25 1985
Date-Received: Sun, 27-Oct-85 05:41:34 EST
References: <482@phri.UUCP> <2887@sun.uucp> <313@bdaemon.UUCP> <2908@sun.uucp> <314@bdaemon.UUCP> <743@whuxl.UUCP>
Reply-To: jqj@cornell.UUCP (J Q Johnson)
Distribution: net
Organization: Cornell Univ. CS Dept.
Lines: 10
Summary: 

Although I personally prefer to write using [] rather than test, it has
the disadvantage of obscuring the generality of sh.  After all, the
conditional can be an arbitrary list, so
	if [ x = y ]; true; then echo yes; fi
prints "yes".  More generally, thinking of  [] as part of a special-purpose
conditional construct obscures the need for the following ";".  I have
several times made the syntax error:
	if [ -r whatever ] then
If I'd been using test, I wouldn't have forgotten the ";", since the
conditional would obviously have needed termination.