question-- Bourne (and C) SHELL

Doug Gwyn gwyn at brl-smoke.ARPA
Sat Aug 16 07:29:09 AEST 1986


In article <150 at humming.UUCP> arturo at humming.UUCP (Arturo Perez) writes:
>In  summary,  how can I take the logical NOT of a command's return value in
>the Bourne shell (which is God's gift to U**X :-)?

Here is how the .funcs function-definition file I source from my .profile
does it:

not(){	$*
	if [ $? -eq 0 ]
	then	return 1
	else	return 0
	fi
}

So I can then use this new "not" command as in:
	if not stuff ...
	then	whatever
	fi

Another more direct trick is:
	if stuff ...
	then	:
	else	whatever
	fi



More information about the Comp.unix mailing list