Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix,net.unix-wizards Subject: Re: question-- Bourne (and C) SHELL Message-ID: <7365@sun.uucp> Date: Wed, 17-Sep-86 15:07:38 EDT Article-I.D.: sun.7365 Posted: Wed Sep 17 15:07:38 1986 Date-Received: Fri, 19-Sep-86 23:26:25 EDT References: <1751@ittatc.ATC.ITT.UUCP> <7028@utzoo.UUCP> <150@humming.UUCP> <6228@sun.uucp> <574@ih1ap.UUCP> Organization: Sun Microsystems, Inc. Lines: 23 Xref: mnetor net.unix:5532 net.unix-wizards:7914 > Correct me if I'm missing something. What's wrong with: > > ls foo > if [ $? != 0 ]; then > echo foo does not exist > fi It doesn't indicate quite as clearly as the other version that the failure/success of "ls" is being tested. It merely indicates that the exit status of "ls" is being compared against 0; you have to associate this with failure/success. (See past discussions in net.lang.c about why Boolean types exist even if you language happens to implement them as integral types.) In addition, 1) "ls" does not always return an exit status indicating whether it could find the files in question or not and 2) "ls" *does* always print the name of the file, if it finds it, or an error, if it doesn't. If "test" had a "does this file exist" predicate, then as I mentioned that would be what you should use. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)