2020-11-20 03:54:37 +00:00
|
|
|
# $NetBSD: varmod-exclam-shell.mk,v 1.4 2020/11/03 18:42:33 rillig Exp $
|
2020-09-05 16:11:04 +00:00
|
|
|
#
|
2020-11-20 03:54:37 +00:00
|
|
|
# Tests for the :!cmd! variable modifier, which evaluates the modifier
|
|
|
|
# argument, independent of the value or the name of the original variable.
|
2020-09-05 16:11:04 +00:00
|
|
|
|
|
|
|
.if ${:!echo hello | tr 'l' 'l'!} != "hello"
|
2020-11-20 03:54:37 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# The output is truncated at the first null byte.
|
|
|
|
# Cmd_Exec returns only a string pointer without length information.
|
2020-11-20 03:54:37 +00:00
|
|
|
# Truncating the output is not necessarily intended but may also be a side
|
|
|
|
# effect from the implementation. Having null bytes in the output of a
|
|
|
|
# shell command is so unusual that it doesn't matter in practice.
|
2020-09-05 16:11:04 +00:00
|
|
|
.if ${:!echo hello | tr 'l' '\0'!} != "he"
|
2020-11-20 03:54:37 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
# The newline at the end of the output is stripped.
|
2020-09-05 16:11:04 +00:00
|
|
|
.if ${:!echo!} != ""
|
2020-11-20 03:54:37 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
# Only the final newline of the output is stripped. All other newlines are
|
|
|
|
# converted to spaces.
|
2020-09-05 16:11:04 +00:00
|
|
|
.if ${:!echo;echo!} != " "
|
2020-11-20 03:54:37 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
2020-11-20 03:54:37 +00:00
|
|
|
# Each newline in the output is converted to a space, except for the newline
|
|
|
|
# at the end of the output, which is stripped.
|
2020-09-05 16:11:04 +00:00
|
|
|
.if ${:!echo;echo;echo;echo!} != " "
|
2020-11-20 03:54:37 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
all:
|
|
|
|
@:;
|