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 make(1): add test for the :Q modifier



details:   https://anonhg.NetBSD.org/src/rev/370b6d11ec83
branches:  trunk
changeset: 1015651:370b6d11ec83
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Oct 29 19:07:45 2020 +0000

description:
make(1): add test for the :Q modifier

diffstat:

 usr.bin/make/unit-tests/varmod-quote.mk |  16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 7ba6863013d3 -r 370b6d11ec83 usr.bin/make/unit-tests/varmod-quote.mk
--- a/usr.bin/make/unit-tests/varmod-quote.mk   Thu Oct 29 19:01:10 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-quote.mk   Thu Oct 29 19:07:45 2020 +0000
@@ -1,9 +1,21 @@
-# $NetBSD: varmod-quote.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varmod-quote.mk,v 1.3 2020/10/29 19:07:45 rillig Exp $
 #
 # Tests for the :Q variable modifier, which quotes the variable value
 # to be used in a shell program.
 
-# TODO: Implementation
+# Any characters that might be interpreted by the shell are escaped.
+# The set of escaped characters is the same, no matter which shell (sh, csh,
+# ksh) is in effect.
+.if ${:Ua b c:Q} != "a\\ b\\ c"
+.  error
+.endif
+
+# The quote modifier only applies if the whole modifier name is "Q".
+# There is no "Qshell" or "Qawk" or "Qregex" or even "Qhtml" variant.
+# All strings except the plain "Q" are interpreted as SysV modifier.
+.if ${:Ua.Qshell:Qshell=replaced} != "a.replaced"
+.  error
+.endif
 
 all:
        @:;



Home | Main Index | Thread Index | Old Index