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