Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make/unit-tests tests/make: demonstrate newline inje...
details: https://anonhg.NetBSD.org/src/rev/469caab55a91
branches: trunk
changeset: 379893:469caab55a91
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jun 25 15:56:02 2021 +0000
description:
tests/make: demonstrate newline injection in .for loop
diffstat:
usr.bin/make/unit-tests/directive-for-escape.exp | 16 +++++++++++++++-
usr.bin/make/unit-tests/directive-for-escape.mk | 10 +++++++++-
2 files changed, 24 insertions(+), 2 deletions(-)
diffs (45 lines):
diff -r 4f39996f7fe4 -r 469caab55a91 usr.bin/make/unit-tests/directive-for-escape.exp
--- a/usr.bin/make/unit-tests/directive-for-escape.exp Fri Jun 25 13:41:33 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.exp Fri Jun 25 15:56:02 2021 +0000
@@ -79,4 +79,18 @@ For: loop body:
make: "directive-for-escape.mk" line 118: eight $$$$ and no cents.
make: "directive-for-escape.mk" line 119: eight dollardollardollardollar and no cents.
make: "directive-for-escape.mk" line 128: eight and no cents.
-exit status 0
+For: end for 1
+For: loop body:
+. info short: ${:U"
+"}
+. info long: ${:U"
+"}
+make: Unclosed variable expression, expecting '}' for modifier "U"" of variable "" with value """
+make: "directive-for-escape.mk" line 134: short: "
+make: "directive-for-escape.mk" line 135: Invalid line type
+make: Unclosed variable expression, expecting '}' for modifier "U"" of variable "" with value """
+make: "directive-for-escape.mk" line 136: long: "
+make: "directive-for-escape.mk" line 137: Invalid line type
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 4f39996f7fe4 -r 469caab55a91 usr.bin/make/unit-tests/directive-for-escape.mk
--- a/usr.bin/make/unit-tests/directive-for-escape.mk Fri Jun 25 13:41:33 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-for-escape.mk Fri Jun 25 15:56:02 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.8 2021/06/24 23:22:17 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.9 2021/06/25 15:56:02 rillig Exp $
#
# Test escaping of special characters in the iteration values of a .for loop.
# These values get expanded later using the :U variable modifier, and this
@@ -127,4 +127,12 @@ closing-brace= } # guard against an
${closing-brace}= <closing-brace> # alternative interpretation
.info eight ${$}${$}${$}${$} and no cents.
+# What happens if the values from the .for loop contain a literal newline?
+# Oops, the newline is added verbatim to the loop body, where it is later
+# interpreted as an ordinary newline.
+.for i in "${.newline}"
+. info short: $i
+. info long: ${i}
+.endfor
+
all:
Home |
Main Index |
Thread Index |
Old Index