varmod-range.mk revision 1.4 1 # $NetBSD: varmod-range.mk,v 1.4 2020/09/27 18:11:31 rillig Exp $
2 #
3 # Tests for the :range variable modifier, which generates sequences
4 # of integers from the given range.
5
6 # The :range modifier generates a sequence of integers, one number per
7 # word of the variable expression's value.
8 .if ${a b c:L:range} != "1 2 3"
9 . error
10 .endif
11
12 # To preserve spaces in a word, they can be enclosed in quotes, just like
13 # everywhere else.
14 .if ${:U first "the second word" third 4 :range} != "1 2 3 4"
15 . error
16 .endif
17
18 # The :range modifier takes the number of words from the value of the
19 # variable expression. If that expression is undefined, the range is
20 # undefined as well. This should not come as a surprise.
21 .if "${:range}" != ""
22 . error
23 .endif
24
25 # The :range modifier can be given a parameter, which makes the generated
26 # range independent from the value or the name of the variable expression.
27 #
28 # XXX: As of 2020-09-27, the :range=... modifier does not turn the undefined
29 # expression into a defined one. This looks like an oversight.
30 .if "${:range=5}" != ""
31 . error
32 .endif
33
34 all:
35 @echo ${a b c:L:rang} # modifier name too short
36 @echo ${a b c:L:range} # ok
37 @echo ${a b c:L:rango} # misspelled
38 @echo ${a b c:L:ranger} # modifier name too long
39