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: <2908@sun.uucp> Date: Fri, 18-Oct-85 15:52:12 EDT Article-I.D.: sun.2908 Posted: Fri Oct 18 15:52:12 1985 Date-Received: Mon, 21-Oct-85 07:13:32 EDT References: <482@phri.UUCP> <2887@sun.uucp> <313@bdaemon.UUCP> Distribution: net Organization: Sun Microsystems, Inc. Lines: 18 > if test -f "$1" <= 15 keystrokes + > vs. > if [ -f "$1" ] <= 14 keystrokes + > > Which is more readable? The latter, obviously; it reads more like a conditional statement rather than a command. It may be *implemented* as a command (which, if the command isn't builtin, slows it down - somebody who complained that "test" shouldn't be built in was later seen using a "case" statement instead of an "if" and a "test" in order to make it run faster), but that fact isn't relevant to understanding what it *does*. Good grief, do you think that people use the square bracket to save one measly keystroke? That's not why it's there - it's there to improve the readability of the statement. Guy Harris