xref: /freebsd/contrib/bmake/unit-tests/varmod-exclam-shell.mk (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1# $NetBSD: varmod-exclam-shell.mk,v 1.4 2020/11/03 18:42:33 rillig Exp $
2#
3# Tests for the :!cmd! variable modifier, which evaluates the modifier
4# argument, independent of the value or the name of the original variable.
5
6.if ${:!echo hello | tr 'l' 'l'!} != "hello"
7.  error
8.endif
9
10# The output is truncated at the first null byte.
11# Cmd_Exec returns only a string pointer without length information.
12# Truncating the output is not necessarily intended but may also be a side
13# effect from the implementation.  Having null bytes in the output of a
14# shell command is so unusual that it doesn't matter in practice.
15.if ${:!echo hello | tr 'l' '\0'!} != "he"
16.  error
17.endif
18
19# The newline at the end of the output is stripped.
20.if ${:!echo!} != ""
21.  error
22.endif
23
24# Only the final newline of the output is stripped.  All other newlines are
25# converted to spaces.
26.if ${:!echo;echo!} != " "
27.  error
28.endif
29
30# Each newline in the output is converted to a space, except for the newline
31# at the end of the output, which is stripped.
32.if ${:!echo;echo;echo;echo!} != "   "
33.  error
34.endif
35
36all:
37	@:;
38