Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site bdaemon.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!hao!nbires!bdaemon!carl From: carl@bdaemon.UUCP (carl) Newsgroups: net.unix-wizards Subject: Re: In sh, is '[' a portable synonym for 'test'? Message-ID: <313@bdaemon.UUCP> Date: Tue, 15-Oct-85 10:57:44 EDT Article-I.D.: bdaemon.313 Posted: Tue Oct 15 10:57:44 1985 Date-Received: Sat, 19-Oct-85 03:54:28 EDT References: <482@phri.UUCP> <2887@sun.uucp> Distribution: net Organization: Daemon Assoc., Boulder, CO Lines: 21 > > > > 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 > > .... > > 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 > ..... > GUy Harris I have absolutely no arguments with Guy's message, but would like to point out that the [ condition ] construct saves only one keystroke at the expense of readability. E.g.: if test -f "$1" <= 15 keystrokes + vs. if [ -f "$1" ] <= 14 keystrokes + Which is more readable? Note that the spaces around [] are MANDATORY. Carl Brandauer