Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!wugate!uunet!ateng!chip From: chip@ateng.com (Chip Salzenberg) Newsgroups: comp.unix.questions Subject: Re: How do I ask "if NOT" in shell? Message-ID: <25489D13.21849@ateng.com> Date: 27 Oct 89 18:23:14 GMT References: <28381@shemp.CS.UCLA.EDU> <2558@auspex.auspex.com> Organization: A T Engineering, Tampa, FL Lines: 24 Several people, including Dave Hitz, suggest variations on: NOT() { ${1+"$@"} test $? -ne 0 } I love it! It's simple and it works. However, Dave Hitz asserts: >Picky people may observe that the arguments to NOT get expanded by >the shell twice, but I've never been caught by this. In fact, they do not get expanded twice. The effect of "$@", as opposed to "$*", is to expand the shell function's arguments as if they were _individually_ quoted. Thus they will not be expanded (again) in the shell function. Unfortunately, if $# is zero, "$@" expands to "" instead of nothing. Thus the need for the ${1+"$@"} hack. [sigh] -- You may redistribute this article only to those who may freely do likewise. Chip Salzenberg at A T Engineering; or "'Why do we post to Usenet?' Naturally, the answer is, 'To get a response.'" -- Brad "Flame Me" Templeton