xref: /freebsd/contrib/bmake/unit-tests/cond-late.mk (revision e17f5b1d307b7b8910d67883e57a9604305906d5)
1# $NetBSD: cond-late.mk,v 1.1 2020/04/29 23:15:21 rillig Exp $
2#
3# Using the :? modifier, variable expressions can contain conditional
4# expressions that are evaluated late.  Any variables appearing in these
5# conditions are expanded before parsing the condition.  This is
6# different from many other places.
7#
8# Because of this, variables that are used in these lazy conditions
9# should not contain double-quotes, or the parser will probably fail.
10#
11# They should also not contain operators like == or <, since these are
12# actually interpreted as these operators. This is demonstrated below.
13#
14# If the order of evaluation were to change to first parse the condition
15# and then expand the variables, the output would change from the
16# current "yes no" to "yes yes", since both variables are non-empty.
17
18COND.true=	"yes" == "yes"
19COND.false=	"yes" != "yes"
20
21all:
22	@echo ${ ${COND.true} :?yes:no}
23	@echo ${ ${COND.false} :?yes:no}
24