aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/varparse-mod.mk
blob: c5fa6f5ece71fd5cca5182784148f70c0ece0085 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# $NetBSD: varparse-mod.mk,v 1.2 2023/11/19 21:47:52 rillig Exp $

# Tests for parsing expressions with modifiers.

# As of 2020-10-02, the below condition does not result in a parse error.
# The condition contains two separate mistakes.  The first mistake is that
# the :!cmd! modifier is missing the closing '!'.  The second mistake is that
# there is a stray '}' at the end of the whole condition.
#
# As of 2020-10-02, the actual parse result of this condition is a single
# expression with 2 modifiers. The first modifier is
# ":!echo "\$VAR"} !".  Afterwards, the parser optionally skips a ':' (at the
# bottom of ApplyModifiers) and continues with the next modifier, in this case
# "= "value"", which is interpreted as a SysV substitution modifier with an
# empty left-hand side, thereby appending the string " "value"" to each word
# of the expression.
#
# As of 2020-10-02, some modifiers ensure that they are followed by either a
# ':' or the closing brace or parenthesis of the expression.  The modifiers
# that don't ensure this are (in order of appearance in ApplyModifier):
#	:@var@replacement@
#	:_
#	:L
#	:P
#	:!cmd!
#	:gmtime=...
#	:localtime=...
#	:M (because '}' and ')' are treated the same)
#	:N (because '}' and ')' are treated the same)
#	:S
#	:C
#	:range=...
# On the other hand, these modifiers ensure that they are followed by a
# delimiter:
#	:D
#	:U
#	:[...]
#	:gmtime (if not followed by '=')
#	:hash (if not followed by '=')
#	:localtime (if not followed by '=')
#	:t
#	:q
#	:Q
#	:T
#	:H
#	:E
#	:R
#	:range (if not followed by '=')
#	:O
#	:u
#	:sh
# These modifiers don't care since they reach until the closing character
# of the expression, which is either ')' or '}':
#	::= (as well as the other assignment modifiers)
#	:?
#
.if ${:!echo "\$VAR"} != "value"}
.endif

all:
	@: