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