1 # $NetBSD: varmod-shell.mk,v 1.11 2024/08/29 20:20:37 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: Command "echo word; (exit 13)" exited with status 13 25 .if ${:!echo word; (exit 13)!} != "word" 26 . error 27 .endif 28 # expect+1: warning: Command "echo word; (exit 13)" exited with status 13 29 .if ${:Uprevious value:!echo word; (exit 13)!} != "word" 30 . error 31 .endif 32 33 34 .MAKEFLAGS: -dv # to see the "Capturing" debug output 35 # expect+1: warning: Command "echo word; (exit 13)" exited with status 13 36 _:= ${:!echo word; ${:U(exit 13)}!} 37 .MAKEFLAGS: -d0 38 39 40 all: 41