xref: /freebsd/contrib/bmake/unit-tests/varmod-shell.mk (revision b0c40a00a67f611868fc0f10bde6b28eb75931be)
1*b0c40a00SSimon J. Gerraty# $NetBSD: varmod-shell.mk,v 1.6 2021/02/14 20:16:17 rillig Exp $
22c3632d1SSimon J. Gerraty#
3*b0c40a00SSimon J. Gerraty# Tests for the ':!cmd!' variable modifier, which runs the shell command
4*b0c40a00SSimon 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
23e2eeea75SSimon J. Gerraty# command that was executed.  It's strange that such a simple bug could
24e2eeea75SSimon J. Gerraty# survive such a long time.
25e2eeea75SSimon J. Gerraty.if ${:!echo word; false!} != "word"
26e2eeea75SSimon J. Gerraty.  error
27e2eeea75SSimon J. Gerraty.endif
28e2eeea75SSimon J. Gerraty.if ${:Uprevious value:!echo word; false!} != "word"
29e2eeea75SSimon J. Gerraty.  error
30e2eeea75SSimon J. Gerraty.endif
31e2eeea75SSimon J. Gerraty
322c3632d1SSimon J. Gerratyall:
33