Module Name: src
Committed By: rillig
Date: Sun Oct 18 21:36:22 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.exp varmod-assign.mk
Log Message:
make(1): explain existing tests for the ::= assignment modifiers
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-assign.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.5 src/usr.bin/make/unit-tests/varmod-assign.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.5 Tue Aug 25 21:16:53 2020
+++ src/usr.bin/make/unit-tests/varmod-assign.exp Sun Oct 18 21:36:22 2020
@@ -11,7 +11,7 @@ mod-assign-nested: else2e2
mod-assign-nested: then3t3
mod-assign-nested: else4e4
make: Bad modifier `:' for
-value}
+mod-assign-empty: value}
make: Bad modifier `:' for
mod-assign-empty: overwritten}
mod-assign-empty: VAR=overwritten
Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.6 src/usr.bin/make/unit-tests/varmod-assign.mk:1.7
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.6 Tue Aug 25 21:16:53 2020
+++ src/usr.bin/make/unit-tests/varmod-assign.mk Sun Oct 18 21:36:22 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.6 2020/08/25 21:16:53 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.7 2020/10/18 21:36:22 rillig Exp $
#
# Tests for the obscure ::= variable modifiers, which perform variable
# assignments during evaluation, just like the = operator in C.
@@ -51,13 +51,25 @@ SINK3:= ${1:?${THEN3::=then3${IT3::=t3}}
SINK4:= ${0:?${THEN4::=then4${IT4::=t4}}:${ELSE4::=else4${IE4::=e4}}}${THEN4}${ELSE4}${IT4}${IE4}
mod-assign-empty:
- # Assigning to the empty variable would obviously not work since that variable
- # is write-protected. Therefore it is rejected early as a "bad modifier".
- @echo ${::=value}
+ # Assigning to the empty variable would obviously not work since that
+ # variable is write-protected. Therefore it is rejected early with a
+ # "Bad modifier" message.
+ #
+ # XXX: The error message is hard to read since the variable name is
+ # empty. This leads to a trailing space in the error message.
+ @echo $@: ${::=value}
+
+ # In this variant, it is not as obvious that the name of the
+ # expression is empty. Assigning to it is rejected as well, with the
+ # same "Bad modifier" message.
+ #
+ # XXX: The error message is hard to read since the variable name is
+ # empty. This leads to a trailing space in the error message.
@echo $@: ${:Uvalue::=overwritten}
- # The :L modifier sets the variable's value to its name.
- # Since the name is still "VAR", assigning to that variable works.
+ # The :L modifier sets the value of the expression to its variable
+ # name. The name of the expression is "VAR", therefore assigning to
+ # that variable works.
@echo $@: ${VAR:L::=overwritten} VAR=${VAR}
mod-assign-parse: