[comp.unix.questions] Re^4: Bourne Shell: Variable defined?

maart@cs.vu.nl (Maarten Litmaath) (03/23/89)

chris@mimsy.UUCP (Chris Torek) writes:
\	if [ "${vax+X}" ]; then echo is set; else echo not set; fi
             ^        ^
	     not needed

[ ${foo+bar} ] && echo core || echo dumped

(In the mythical True C Shell one can say:

	echo $?foo ? core : dumped
)
-- 
 Modeless editors and strong typing:   |Maarten Litmaath @ VU Amsterdam:
   both for people with weak memories. |maart@cs.vu.nl, mcvax!botter!maart

chris@mimsy.UUCP (Chris Torek) (03/26/89)

>I wrote:
>>	if [ "${vax+X}" ]; then echo is set; else echo not set; fi

In article <2209@solo2.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) notes
that the ""s are not needed (true) and suggests instead:

	[ ${foo+bar} ] && echo core || echo dumped

Alas, `||' misbehaves in some `sh'es when -e is set, whereas `if'
misbehaves in fewer (but not none).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris