aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/cond-late.mk
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2020-05-20 19:34:48 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2020-05-20 19:34:48 +0000
commitb897d72a5adf5cfad8c79f90e155bae99bdde48c (patch)
tree0e06330d11aebdabb067f53e790c38664297ec4e /unit-tests/cond-late.mk
parent14ade6f03183ea07683d6775a858bfd51fac9990 (diff)
downloadsrc-b897d72a5adf5cfad8c79f90e155bae99bdde48c.tar.gz
src-b897d72a5adf5cfad8c79f90e155bae99bdde48c.zip
Notes
Diffstat (limited to 'unit-tests/cond-late.mk')
-rw-r--r--unit-tests/cond-late.mk23
1 files changed, 23 insertions, 0 deletions
diff --git a/unit-tests/cond-late.mk b/unit-tests/cond-late.mk
new file mode 100644
index 000000000000..2eb02b42b920
--- /dev/null
+++ b/unit-tests/cond-late.mk
@@ -0,0 +1,23 @@
+# $NetBSD: cond-late.mk,v 1.1 2020/04/29 23:15:21 rillig Exp $
+#
+# Using the :? modifier, variable expressions can contain conditional
+# expressions that are evaluated late. Any variables appearing in these
+# conditions are expanded before parsing the condition. This is
+# different from many other places.
+#
+# Because of this, variables that are used in these lazy conditions
+# should not contain double-quotes, or the parser will probably fail.
+#
+# They should also not contain operators like == or <, since these are
+# actually interpreted as these operators. This is demonstrated below.
+#
+# If the order of evaluation were to change to first parse the condition
+# and then expand the variables, the output would change from the
+# current "yes no" to "yes yes", since both variables are non-empty.
+
+COND.true= "yes" == "yes"
+COND.false= "yes" != "yes"
+
+all:
+ @echo ${ ${COND.true} :?yes:no}
+ @echo ${ ${COND.false} :?yes:no}