1*e2eeea75SSimon J. Gerraty# $NetBSD: varmod-shell.mk,v 1.5 2020/11/17 20:11:02 rillig Exp $ 22c3632d1SSimon J. Gerraty# 32c3632d1SSimon J. Gerraty# Tests for the :sh variable modifier, which runs the shell command 42c3632d1SSimon J. Gerraty# given by the variable value and returns its output. 5*e2eeea75SSimon J. Gerraty# 6*e2eeea75SSimon J. Gerraty# This modifier has been added on 2000-04-29. 7*e2eeea75SSimon J. Gerraty# 8*e2eeea75SSimon J. Gerraty# See also: 9*e2eeea75SSimon J. Gerraty# ApplyModifier_ShellCommand 102c3632d1SSimon J. Gerraty 112c3632d1SSimon J. Gerraty# TODO: Implementation 122c3632d1SSimon J. Gerraty 13*e2eeea75SSimon J. Gerraty# The command to be run is enclosed between exclamation marks. 14*e2eeea75SSimon J. Gerraty# The previous value of the expression is irrelevant for this modifier. 15*e2eeea75SSimon J. Gerraty# The :!cmd! modifier turns an undefined expression into a defined one. 16*e2eeea75SSimon J. Gerraty.if ${:!echo word!} != "word" 17*e2eeea75SSimon J. Gerraty. error 18*e2eeea75SSimon J. Gerraty.endif 19*e2eeea75SSimon J. Gerraty 20*e2eeea75SSimon J. Gerraty# If the command exits with non-zero, an error message is printed. 21*e2eeea75SSimon J. Gerraty# XXX: Processing continues as usual though. 22*e2eeea75SSimon J. Gerraty# 23*e2eeea75SSimon J. Gerraty# Between 2000-04-29 and 2020-11-17, the error message mentioned the previous 24*e2eeea75SSimon J. Gerraty# value of the expression (which is usually an empty string) instead of the 25*e2eeea75SSimon J. Gerraty# command that was executed. It's strange that such a simple bug could 26*e2eeea75SSimon J. Gerraty# survive such a long time. 27*e2eeea75SSimon J. Gerraty.if ${:!echo word; false!} != "word" 28*e2eeea75SSimon J. Gerraty. error 29*e2eeea75SSimon J. Gerraty.endif 30*e2eeea75SSimon J. Gerraty.if ${:Uprevious value:!echo word; false!} != "word" 31*e2eeea75SSimon J. Gerraty. error 32*e2eeea75SSimon J. Gerraty.endif 33*e2eeea75SSimon J. Gerraty 342c3632d1SSimon J. Gerratyall: 352c3632d1SSimon J. Gerraty @:; 36