How do I ask "if NOT" in shell?

Keith Gabryelski ag at cbmvax.UUCP
Tue Oct 24 12:17:32 AEST 1989


In article <3787 at solo6.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
>kirkaas at 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 at cbmvax.commodore.com     Keith M. Gabryelski      ...!uunet!cbmvax!ag



More information about the Comp.unix.questions mailing list