Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: How do I ask "if NOT" in shell? Message-ID: <3787@solo6.cs.vu.nl> Date: 23 Oct 89 18:38:43 GMT References: <28381@shemp.CS.UCLA.EDU> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 31 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? Unfortunately there doesn't seem to be a clean way to do this. The obvious work-around: if command then : else command fi A cleaner approach: if not command then command fi ...where `not' is defined as the following shell function/script: ${1+"$@"} test $? != 0 SunOS 4.0.3c /bin/sh doesn't like a function to be named `!', a shell script would be OK though. -- A symbolic link is a POINTER to a file, | Maarten Litmaath @ VU Amsterdam: a hard link is the file system's GOTO. | maart@cs.vu.nl, mcsun!botter!maart