summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-08-08 13:09:55 +0000
committerrillig <rillig@NetBSD.org>2020-08-08 13:09:55 +0000
commit0fa02a45a67cc7b3d65fbb325fee7f061b9a984b (patch)
tree84ae0420600472239371d0e426afab6792f7ecb1 /usr.bin/make
parent94a45f86aaa146af65c804fe3a75f4fe9d17d62e (diff)
make(1): add test for the :gmtime modifier with indirect time
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/unit-tests/modmisc.exp3
-rw-r--r--usr.bin/make/unit-tests/modmisc.mk13
2 files changed, 15 insertions, 1 deletions
diff --git a/usr.bin/make/unit-tests/modmisc.exp b/usr.bin/make/unit-tests/modmisc.exp
index 19bd705252d..08695569685 100644
--- a/usr.bin/make/unit-tests/modmisc.exp
+++ b/usr.bin/make/unit-tests/modmisc.exp
@@ -107,6 +107,9 @@ mod-gmtime:
2020
%Y
%Y
+mod-gmtime-indirect:
+make: Unknown modifier '1'
+
mod-localtime:
%Y
2020
diff --git a/usr.bin/make/unit-tests/modmisc.mk b/usr.bin/make/unit-tests/modmisc.mk
index b2ba388294a..d3cc7cd8ad0 100644
--- a/usr.bin/make/unit-tests/modmisc.mk
+++ b/usr.bin/make/unit-tests/modmisc.mk
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.35 2020/08/08 13:03:13 rillig Exp $
+# $Id: modmisc.mk,v 1.36 2020/08/08 13:09:55 rillig Exp $
#
# miscellaneous modifier tests
@@ -30,6 +30,7 @@ all: mod-quote
all: mod-break-many-words
all: mod-remember
all: mod-gmtime
+all: mod-gmtime-indirect
all: mod-localtime
all: mod-hash
all: mod-range
@@ -295,6 +296,16 @@ mod-gmtime:
@echo ${%Y:L:gmtimer=1593536400} # modifier name too long
@echo ${%Y:L:gm=gm:M*}
+mod-gmtime-indirect:
+ @echo $@:
+ # It's not possible to pass the seconds via a variable expression.
+ # Parsing of the :gmtime modifier stops at the '$' and returns to
+ # ApplyModifiers. There, a colon would be skipped but not a dollar.
+ # Parsing continues by looking at the next modifier. Now the ${:U}
+ # is expanded and interpreted as a variable modifier, which results
+ # in the error message "Unknown modifier '1'".
+ @echo ${%Y:L:gmtime=${:U1593536400}}
+
mod-localtime:
@echo $@:
@echo ${%Y:L:localtim=1593536400} # modifier name too short