Subject: Re: make(1) question; purpose of ${ :? : }
To: Luke Mewburn <lukem@NetBSD.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 01/09/2004 00:27:17
>On Fri, 9 Jan 2004 11:23:23 +1100, Luke Mewburn writes:
>>what limitations are there on the expression before the ':?' ?
>>can we do stuff like
>> ${defined(FOO)||${BAR}!=3D"" :?true:false}
Actually you can - sort of.
Problem is you have to prevent ${BAR} being expanded
until it is passed to Cond_EvalExpression().
So the following:
A?=$${USER} == "$B"
B?=x
x:
@echo "The answer for '$A' is ${$A:?yes:no}"
produces:
$ make -f /homes/sjg/make-tests/ternary x
The answer for 'sjg == x' is no
$ make -f /homes/sjg/make-tests/ternary x B=sjg
The answer for 'sjg == sjg' is yes
$
But you can't put the expression directly into the ${:?yes:no} bit.
--sjg