summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/make-quoting/Makefile26
-rw-r--r--regress/make-quoting/files/continue.mk19
-rw-r--r--regress/make-quoting/files/continue.out7
-rw-r--r--regress/make-quoting/files/dblquote.mk13
-rw-r--r--regress/make-quoting/files/dblquote.out2
-rw-r--r--regress/make-quoting/files/for.mk11
-rw-r--r--regress/make-quoting/files/for.out7
-rw-r--r--regress/make-quoting/files/ltarget.mk13
-rw-r--r--regress/make-quoting/files/ltarget.out1
-rw-r--r--regress/make-quoting/files/nestfor.mk17
-rw-r--r--regress/make-quoting/files/nestfor.out1
-rw-r--r--regress/make-quoting/files/quoting.mk16
-rw-r--r--regress/make-quoting/files/quoting.out6
-rw-r--r--regress/make-quoting/files/sglquote.mk16
-rw-r--r--regress/make-quoting/files/sglquote.out6
-rw-r--r--regress/make-quoting/files/vtarget.mk10
-rw-r--r--regress/make-quoting/files/vtarget.out1
-rw-r--r--regress/make-quoting/spec9
18 files changed, 181 insertions, 0 deletions
diff --git a/regress/make-quoting/Makefile b/regress/make-quoting/Makefile
new file mode 100644
index 00000000000..6bab0b9ae55
--- /dev/null
+++ b/regress/make-quoting/Makefile
@@ -0,0 +1,26 @@
+# $NetBSD: Makefile,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+
+DISTNAME= regress-make-1.0
+CATEGORIES= regress
+DISTFILES= # empty
+
+MAINTAINER= rillig@NetBSD.org
+COMMENT= Test Makefile quoting
+
+REGRESS_TESTS= continue dblquote for ltarget nestfor quoting sglquote \
+ vtarget
+
+do-extract:
+ @${_PKG_SILENT}${_PKG_DEBUG} \
+ ${MKDIR} ${WRKSRC:Q}
+
+do-build:
+.for t in ${REGRESS_TESTS}
+ @${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO_MSG} "Running testcase "${t:Q}; \
+ ${MAKE} ${MAKEFLAGS} -s -f ${FILESDIR:Q}/${t:Q}.mk \
+ | diff - ${FILESDIR:Q}/${t:Q}.out
+.endfor
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/regress/make-quoting/files/continue.mk b/regress/make-quoting/files/continue.mk
new file mode 100644
index 00000000000..b82c1946d06
--- /dev/null
+++ b/regress/make-quoting/files/continue.mk
@@ -0,0 +1,19 @@
+# $NetBSD: continue.mk,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+# This file demonstrates that .for variables that end in a backslash are
+# interpreted as line-continuations when they are placed at the end of a
+# line.
+#
+
+LIST= a:\ a:\foo.bar
+
+.PHONY: all
+all:
+.for l in ${LIST}
+ echo ${l:Q}
+ echo "second line"
+.endfor
+.for l in ${LIST}
+ echo ${l:Q}""
+ echo "second line"
+.endfor
diff --git a/regress/make-quoting/files/continue.out b/regress/make-quoting/files/continue.out
new file mode 100644
index 00000000000..5121763c8b0
--- /dev/null
+++ b/regress/make-quoting/files/continue.out
@@ -0,0 +1,7 @@
+a: echo second line
+a:\foo.bar
+second line
+a:\
+second line
+a:\foo.bar
+second line
diff --git a/regress/make-quoting/files/dblquote.mk b/regress/make-quoting/files/dblquote.mk
new file mode 100644
index 00000000000..1c046b7dacb
--- /dev/null
+++ b/regress/make-quoting/files/dblquote.mk
@@ -0,0 +1,13 @@
+# $NetBSD: dblquote.mk,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+# This file demonstrates that quoted strings are interpreted when appying
+# the ``modifiers'', not when creating strings by assignment.
+#
+
+DBLQUOTE= "
+DBLQUOTE+= "a b"
+DBLQUOTE+= "
+
+all:
+ echo ${DBLQUOTE:Q}
+ echo ${DBLQUOTE:M*:Q}
diff --git a/regress/make-quoting/files/dblquote.out b/regress/make-quoting/files/dblquote.out
new file mode 100644
index 00000000000..993bc7a4e52
--- /dev/null
+++ b/regress/make-quoting/files/dblquote.out
@@ -0,0 +1,2 @@
+" "a b" "
+" "a b" "
diff --git a/regress/make-quoting/files/for.mk b/regress/make-quoting/files/for.mk
new file mode 100644
index 00000000000..1d3a65c6d49
--- /dev/null
+++ b/regress/make-quoting/files/for.mk
@@ -0,0 +1,11 @@
+# $NetBSD: for.mk,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+# .for loops don't interpret variables in sh(1) mode, but split them at
+# whitespace.
+
+LIST_1= 1 2 "3 3" '4 ' 5'5'5"5"5
+
+all:
+.for i in ${LIST_1}
+ echo ${i:Q}
+.endfor
diff --git a/regress/make-quoting/files/for.out b/regress/make-quoting/files/for.out
new file mode 100644
index 00000000000..831fb34aeb1
--- /dev/null
+++ b/regress/make-quoting/files/for.out
@@ -0,0 +1,7 @@
+1
+2
+"3
+3"
+'4
+'
+5'5'5"5"5
diff --git a/regress/make-quoting/files/ltarget.mk b/regress/make-quoting/files/ltarget.mk
new file mode 100644
index 00000000000..46ec09604c2
--- /dev/null
+++ b/regress/make-quoting/files/ltarget.mk
@@ -0,0 +1,13 @@
+# $NetBSD: ltarget.mk,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+# This file demonstrates that the ${.TARGET} variable must be quoted when
+# the target is specified directly.
+#
+# See also vtarget.
+#
+
+all: foo`date`
+
+.PHONY: foo`date`
+foo`date`:
+ echo ${.TARGET:Q}
diff --git a/regress/make-quoting/files/ltarget.out b/regress/make-quoting/files/ltarget.out
new file mode 100644
index 00000000000..f792decb70a
--- /dev/null
+++ b/regress/make-quoting/files/ltarget.out
@@ -0,0 +1 @@
+foo`date`
diff --git a/regress/make-quoting/files/nestfor.mk b/regress/make-quoting/files/nestfor.mk
new file mode 100644
index 00000000000..43b2a802536
--- /dev/null
+++ b/regress/make-quoting/files/nestfor.mk
@@ -0,0 +1,17 @@
+# $NetBSD: nestfor.mk,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+# This file tests what happens if the same variable name is used in
+# nested .for loops.
+#
+# The result is somewhat surprising, in that the outer i is used.
+#
+
+X= # empty
+.for i in a b c
+. for i in 0 1 2
+X+= ${i}
+. endfor
+.endfor
+
+all:
+ echo ${X:M*:Q}
diff --git a/regress/make-quoting/files/nestfor.out b/regress/make-quoting/files/nestfor.out
new file mode 100644
index 00000000000..330d8f1a291
--- /dev/null
+++ b/regress/make-quoting/files/nestfor.out
@@ -0,0 +1 @@
+a a a b b b c c c
diff --git a/regress/make-quoting/files/quoting.mk b/regress/make-quoting/files/quoting.mk
new file mode 100644
index 00000000000..170aa8e0977
--- /dev/null
+++ b/regress/make-quoting/files/quoting.mk
@@ -0,0 +1,16 @@
+# $NetBSD: quoting.mk,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+# This file demonstrates various techniques for quoting variables when
+# passing them to the shell.
+#
+
+EVIL_STRING?= " "
+
+.PHONY: all
+all:
+ echo ${EVIL_STRING}
+ echo ${EVIL_STRING:Q}
+ echo "${EVIL_STRING}"
+ echo "${EVIL_STRING:Q}"
+ echo ${EVIL_STRING:Q}""
+ echo x${EVIL_STRING:Q} | sed 1s,.,,
diff --git a/regress/make-quoting/files/quoting.out b/regress/make-quoting/files/quoting.out
new file mode 100644
index 00000000000..23a35cfc845
--- /dev/null
+++ b/regress/make-quoting/files/quoting.out
@@ -0,0 +1,6 @@
+
+" "
+
+"\ \ \ "
+" "
+" "
diff --git a/regress/make-quoting/files/sglquote.mk b/regress/make-quoting/files/sglquote.mk
new file mode 100644
index 00000000000..7105b396249
--- /dev/null
+++ b/regress/make-quoting/files/sglquote.mk
@@ -0,0 +1,16 @@
+# $NetBSD: sglquote.mk,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+# This file demonstrates the differences between single and double
+# quotes.
+#
+
+STR_1= '\''\''a b' 'z'
+STR_2= "\""\""a b" "z"
+
+all:
+ echo ${STR_1}
+ echo ${STR_1:Q}
+ echo ${STR_1:M*:Q}
+ echo ${STR_2}
+ echo ${STR_2:Q}
+ echo ${STR_2:M*:Q}
diff --git a/regress/make-quoting/files/sglquote.out b/regress/make-quoting/files/sglquote.out
new file mode 100644
index 00000000000..4b13b7ae9bd
--- /dev/null
+++ b/regress/make-quoting/files/sglquote.out
@@ -0,0 +1,6 @@
+\\a b z
+'\''\''a b' 'z'
+'\''\''a b' 'z'
+""a b z
+"\""\""a b" "z"
+"\""\""a b" "z"
diff --git a/regress/make-quoting/files/vtarget.mk b/regress/make-quoting/files/vtarget.mk
new file mode 100644
index 00000000000..704e306b213
--- /dev/null
+++ b/regress/make-quoting/files/vtarget.mk
@@ -0,0 +1,10 @@
+# $NetBSD: vtarget.mk,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+# This file demonstrates that the ${.TARGET} variable does not have to
+# be quoted when the target is specified by a quoted variable.
+#
+
+FOO= a b `date`
+
+${FOO:Q}:
+ echo ${.TARGET}
diff --git a/regress/make-quoting/files/vtarget.out b/regress/make-quoting/files/vtarget.out
new file mode 100644
index 00000000000..fbda2ab55db
--- /dev/null
+++ b/regress/make-quoting/files/vtarget.out
@@ -0,0 +1 @@
+a b `date`
diff --git a/regress/make-quoting/spec b/regress/make-quoting/spec
new file mode 100644
index 00000000000..6fb91fd1bab
--- /dev/null
+++ b/regress/make-quoting/spec
@@ -0,0 +1,9 @@
+# $NetBSD: spec,v 1.1.1.1 2005/05/15 21:10:16 rillig Exp $
+#
+
+MAKEARGS_TEST=build
+MAKEARGS_CLEAN=clean
+
+check_result() {
+ exit_status 0
+}