Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ncoast.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!lll-crg!ucdavis!ucbvax!decvax!cwruecmp!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon Allbery) Newsgroups: net.unix-wizards Subject: test vs. [ Message-ID: <866@ncoast.UUCP> Date: Sun, 27-Oct-85 18:53:34 EST Article-I.D.: ncoast.866 Posted: Sun Oct 27 18:53:34 1985 Date-Received: Wed, 30-Oct-85 06:38:46 EST References: <313@bdaemon.UUCP> <2000031@ccvaxa> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: net.unix-wizards Organization: Cleveland Public Access UNIX, Cleveland, OH Lines: 33 Keywords: command-syntax Summary: It depends on the operation Expires: Quoted from <2000031@ccvaxa> ["Re: In sh, is '[' a portable synony"], by preece@ccvaxa.UUCP... +--------------- | > if test -f "$1" <= 15 keystrokes +| > vs. | > if [ -f "$1" ] <= 14 keystrokes + | > | > Which is more readable? Note that the spaces around [] are MANDATORY. | > /* Written 9:57 am Oct 15, 1985 by carl@bdaemon.UUCP in | > ccvaxa:net.unix-wizards */ | ---------- | Well, readability is very much in the eye of the beholder. I much | prefer the second form, which I gather you think is less readable. +--------------- In general, when I am using the math/binary ops I use [, but when I want to use the file predicates I use test. Thus: if [ $expr -gt 5 ]; then but if test -s /tmp/toMl$$; then -- ``Youth, you are guilty of muddy thinking.'' Mentor ncoast!allbery@Case.CSNet (ncoast!allbery%Case.CSNet@CSNet-Relay.ARPA) ..decvax!cwruecmp!ncoast!bsa -- maybe ..genrad!mit-eddie!futura!ncoast!allbery 6615 Center St., Mentor, OH 44060 (I moved) --Phone: +01 216 974 9210 CIS 74106,1032 -- MCI MAIL BALLBERY (WARNING: I am only a part-time denizen...) ncoast is dead, long live ncoast!