Subject: Re: Syntax of :? in Makefiles
To: None <tech-userlevel@NetBSD.org>
From: Klaus Heinz <k.heinz.mai.sieben@kh-22.de>
List: tech-userlevel
Date: 05/26/2007 11:59:41
Simon Gerraty wrote:
> One thing to keep in mind is that many macro expansions behave differently
> in conditional expressions - which can be very frustrating. I have a
> vague recollection that the scope that is searched is a factor.
> X=${"${VAR:Mmatch}":?yes:no}
^^^^^^^^^^^^^^^
Why do we need the double quotes? I can see that ${VAR:Mmatch} may
be necessary to limit the pattern but cannot explain the quotes.
Since the man page does not mention them I never tried it this way.
works without quotes
X=${empty(VAR):?yes:no}
always yes
X=${"empty(VAR)":?yes:no}
syntax error "bad conditional expression"
X=${empty(VAR:Mmatch):?yes:no}
> a:
> @echo X=${X}
>
> b:
> .if ${X} == "yes"
> @echo ok
> .else
> @echo no
> .endif
>
> $ make a b
> X=no
> ok
^^
Can anyone explain this result?
The output of "make -dcv b" does not shed any light on this, "yes" is
not shown anywhere except in the definition of global variable X.
ciao
Klaus