xref: /freebsd/contrib/bmake/unit-tests/varname-dot-newline.mk (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
1# $NetBSD: varname-dot-newline.mk,v 1.6 2023/01/26 20:48:18 sjg Exp $
2#
3# Tests for the special .newline variable, which contains a single newline
4# character (U+000A).
5
6
7# https://austingroupbugs.net/view.php?id=1549 proposes:
8# > After all macro expansion is complete, when an escaped <newline> is
9# > found in a command line in a makefile, the command line that is executed
10# > shall contain the <backslash>, the <newline>, and the next line, except
11# > that the first character of the next line shall not be included if it is
12# > a <tab>.
13#
14# The above quote assumes that each resulting <newline> character has a "next
15# line", but that's not how the .newline variable works.
16BACKSLASH_NEWLINE:=	\${.newline}
17
18
19# Check that .newline is read-only
20
21NEWLINE:=	${.newline}
22
23.newline=	overwritten
24
25.if ${.newline} != ${NEWLINE}
26.  error The .newline variable can be overwritten.  It should be read-only.
27.endif
28
29all:
30	@echo 'first${.newline}second'
31	@echo 'backslash newline: <${BACKSLASH_NEWLINE}>'
32