3
$description = "Test BSD-style shell assignments (VAR != VAL) for variables.";
7
# TEST 0: Basic shell assignment (!=).
12
demo1!=printf \' 1 2 3\n4\n\n5 \n \n 6\n\n\n\n\'
13
demo2 != printf \'7 8\n \'
14
demo3 != printf \'$$(demo2)\'
15
demo4 != printf \' 2 3 \n\'
16
demo5 != printf \' 2 3 \n\n\'
17
all: ; @echo "<$(demo1)> <$(demo2)> <$(demo3)> <$(demo4)> <${demo5}>"
19
'', "< 1 2 3 4 5 6 > <7 8 > <7 8 > < 2 3 > < 2 3 >\n");
21
# TEST 1: Handle '#' the same way as BSD make
25
hash != printf \'\043\'
26
foo2!= echo "bar$(hash)baz"
28
all: ; @echo "<$(foo1)> <$(hash)> <$(foo2)>"
30
'', "<bar> <#> <bar#baz>\n");
32
# TEST 2: shell assignment variables (from !=) should be recursive.
33
# Note that variables are re-evaluated later, so the shell can output
34
# a value like $(XYZZY) as part of !=. The $(XYZZY) will be EVALUATED
35
# when the value containing it is evaluated. On the negative side, this
36
# means if you don't want this, you need to escape dollar signs as $$.
37
# On the positive side, it means that shell programs can output macros
38
# that are then evaluated as they are traditionally evaluated.. and that
39
# you can use traditional macro evaluation semantics to implement !=.
42
XYZZY = fiddle-dee-dee
44
VAR3 != printf \'%s\' \'$(dollar)(XYZZY)\'
46
all: ; @echo "<$(VAR3)>"
48
'', "<fiddle-dee-dee>\n");
51
# TEST 3: Overrides invoke shell anyway; they just don't store the result
52
# in a way that is visible.
56
override != echo abc > ,abc ; cat ,abc
58
all: ; @echo "<$(override)>" ; cat ,abc
60
'override=xyz', "<xyz>\nabc\n");