varmod-shell.mk revision 1.8 1 # $NetBSD: varmod-shell.mk,v 1.8 2024/06/30 11:00:06 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 # expect+1: warning: while evaluating "${:!echo word; false!} != "word"": "echo word; false" returned non-zero status
25 .if ${:!echo word; false!} != "word"
26 . error
27 .endif
28 # expect+1: warning: while evaluating "${:Uprevious value:!echo word; false!} != "word"": "echo word; false" returned non-zero status
29 .if ${:Uprevious value:!echo word; false!} != "word"
30 . error
31 .endif
32
33
34 .MAKEFLAGS: -dv # to see the "Capturing" debug output
35 # expect+1: warning: while evaluating "${:!echo word; ${:Ufalse}!}": "echo word; false" returned non-zero status
36 _:= ${:!echo word; ${:Ufalse}!}
37 .MAKEFLAGS: -d0
38
39
40 all:
41