Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!uunet!cbmvax!ag From: ag@cbmvax.UUCP (Keith Gabryelski) Newsgroups: comp.unix.questions Subject: Re: How do I ask "if NOT" in shell? Message-ID: <8243@cbmvax.UUCP> Date: 24 Oct 89 02:17:32 GMT References: <28381@shemp.CS.UCLA.EDU> <3787@solo6.cs.vu.nl> Reply-To: ag@cbmvax.UUCP (Keith Gabryelski) Organization: Commodore Technology, West Chester, PA Lines: 31 In article <3787@solo6.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >kirkaas@oahu.cs.ucla.edu (paul kirkaas) writes: >\How can one say "if not" in a shellscript; that is, execute the body of >\the "then" only if the argument of "if" returns a non-zero exit status? It is actually a toss up for me between: > if not command > then > command > fi > >...where `not' is defined as the following shell function/script: > > ${1+"$@"} > test $? != 0 and until command do : # do some stuff break # explict break done Agreed that there should be a cleaner way. Pax, Keith -- "It took no computation to dance to the rock 'n roll station" -- VU ag@cbmvax.commodore.com Keith M. Gabryelski ...!uunet!cbmvax!ag