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