Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!ihnp4!ih1ap!sja From: sja@ih1ap.UUCP (Steve Alesch) Newsgroups: net.unix,net.unix-wizards Subject: Re: question-- Bourne (and C) SHELL Message-ID: <574@ih1ap.UUCP> Date: Thu, 11-Sep-86 23:38:56 EDT Article-I.D.: ih1ap.574 Posted: Thu Sep 11 23:38:56 1986 Date-Received: Sat, 13-Sep-86 04:21:55 EDT References: <1751@ittatc.ATC.ITT.UUCP> <7028@utzoo.UUCP> <150@humming.UUCP> <6228@sun.uucp> Organization: AT&T Bell Labs, Naperville, IL Lines: 45 Xref: watmath net.unix:9157 net.unix-wizards:19537 Summary: what's wrong with ``[ $? != 0 ]''? In article <6228@sun.uucp>, guy@sun.uucp (Guy Harris) writes: > > The key thing here is the ability to NOT the value of status. How is > > this similar thing done in Bourne shell. > > > > if ! ls foo > > then > > echo foo does not exist > > fi > > Try > > if ls foo > then > : > else > echo foo does not exist > fi > > The ":" is the pseudo-comment from old Bourne shells; it's really a command > that does nothing. > > Not the cleanest syntax, but that's life. (However, I'd rather have a shell > that requires that crud, but allows you to redirect the output of a "for" > loop, than one that permits you to negate exit status directly but won't let > you redirect the output of loops! At least with the Bourne shell you can > get around the inability to negate exit status fairly easily.) > > However, you may be better off doing > > if test ! -f foo > > or something like that; unfortunately, "test" doesn't have a predicate for > "just test whether it exists", but you may really want a more restrictive > predicate anyway. Correct me if I'm missing something. What's wrong with: ls foo if [ $? != 0 ]; then echo foo does not exist fi -- Steve Alesch AT&T (312)510-7881, ...!ihnp4!ih1ap!sja