Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!dcl-cs!nott-cs!anw From: anw@nott-cs.UUCP Newsgroups: net.unix,net.unix-wizards Subject: Re: question-- Bourne (and C) SHELL Message-ID: <268@tuck.nott-cs.UUCP> Date: Wed, 20-Aug-86 07:05:54 EDT Article-I.D.: tuck.268 Posted: Wed Aug 20 07:05:54 1986 Date-Received: Thu, 21-Aug-86 04:11:29 EDT References: <1751@ittatc.ATC.ITT.UUCP> <7028@utzoo.UUCP> <150@humming.UUCP> <6228@sun.uucp> Reply-To: anw@nott-cs.UUCP (Dr A. N. Walker) Organization: Maths Department, University of Nottingham, ENGLAND. Lines: 27 Xref: mnetor net.unix:5247 net.unix-wizards:7622 In article <6228@sun.uucp> guy@sun.uucp (Guy Harris) writes: >Try > > if ls foo > then > : > else > echo foo does not exist > fi Or you could try ls foo || echo foo does not exist In complicated situations, "if ... then ... else ... fi" is clearer, but where there is only one subsidiary command I think "&&" and "||" can tidy up shell scripts quite a lot. I often use (V7 with SV shell) something like [ -w foo ] || fault "can't write to foo" where "fault" is a suitable function, such as fault () { echo $0: error, "$@" 1>&2; exit 1; } -- Andy Walker, Maths Dept, Nottm Univ