varmod-shell.mk revision 1.7 1 # $NetBSD: varmod-shell.mk,v 1.7 2022/01/10 20:32:29 rillig Exp $
2 #
3 # Tests for the ':!cmd!' variable modifier, which runs the shell command
4 # given by the variable modifier and returns its output.
5 #
6 # This modifier has been added on 2000-04-29.
7 #
8 # See also:
9 # ApplyModifier_ShellCommand
10
11 # The command to be run is enclosed between exclamation marks.
12 # The previous value of the expression is irrelevant for this modifier.
13 # The :!cmd! modifier turns an undefined expression into a defined one.
14 .if ${:!echo word!} != "word"
15 . error
16 .endif
17
18 # If the command exits with non-zero, an error message is printed.
19 # XXX: Processing continues as usual though.
20 #
21 # Between 2000-04-29 and 2020-11-17, the error message mentioned the previous
22 # value of the expression (which is usually an empty string) instead of the
23 # command that was executed.
24 .if ${:!echo word; false!} != "word"
25 . error
26 .endif
27 .if ${:Uprevious value:!echo word; false!} != "word"
28 . error
29 .endif
30
31
32 .MAKEFLAGS: -dv # to see the actual command
33 _:= ${:!echo word; ${:Ufalse}!}
34 .MAKEFLAGS: -d0
35
36 all:
37