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 that demonstrates ...
details: https://anonhg.NetBSD.org/src/rev/69f26ecb2309
branches: trunk
changeset: 936934:69f26ecb2309
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 09 08:03:31 2020 +0000
description:
make(1): add test that demonstrates possible delimiters for :S
diffstat:
usr.bin/make/unit-tests/modmisc.exp | 27 +++++++++++++++++++++++++++
usr.bin/make/unit-tests/modmisc.mk | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 63 insertions(+), 1 deletions(-)
diffs (95 lines):
diff -r 82759bfacf6b -r 69f26ecb2309 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp Sun Aug 09 07:41:14 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp Sun Aug 09 08:03:31 2020 +0000
@@ -25,6 +25,33 @@
:a c:
:x__ 3 x__ 3:
12345
+mod-subst-delimiter:
+1 two 3 horizontal tabulator
+1 two 3 space
+1 two 3 exclamation mark
+1 two 3 double quotes
+1 two 3 hash
+1 two 3 dollar
+1 two 3 percent
+1 two 3 apostrophe
+1 two 3 opening parenthesis
+1 two 3 closing parenthesis
+1 two 3 digit
+1 two 3 colon
+1 two 3 less than sign
+1 two 3 equal sign
+1 two 3 greater than sign
+1 two 3 question mark
+1 two 3 at
+1 two 3 letter
+1 two 3 opening bracket
+1 two 3 backslash
+1 two 3 closing bracket
+1 two 3 caret
+1 two 3 opening brace
+1 two 3 vertical line
+1 two 3 closing brace
+1 two 3 tilde
mod-subst-chain:
A B c.
make: Unknown modifier 'i'
diff -r 82759bfacf6b -r 69f26ecb2309 usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk Sun Aug 09 07:41:14 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk Sun Aug 09 08:03:31 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.38 2020/08/09 07:41:14 rillig Exp $
+# $Id: modmisc.mk,v 1.39 2020/08/09 08:03:31 rillig Exp $
#
# miscellaneous modifier tests
@@ -17,6 +17,7 @@
all: modvar modvarloop modsysv mod-HTE emptyvar undefvar
all: mod-subst
+all: mod-subst-delimiter
all: mod-subst-chain
all: mod-regex
all: mod-loop-varname mod-loop-resolve mod-loop-varname-dollar
@@ -138,6 +139,40 @@
@echo :${:U1 2 3 1 2 3:S,1 2,___,Wg:S,_,x,:Q}:
@echo ${:U12345:S,,sep,g:Q}
+# The :S and :C modifiers accept an arbitrary character as the delimiter,
+# including characters that are otherwise used as escape characters or
+# interpreted in a special way. This can be used to confuse humans.
+mod-subst-delimiter:
+ @echo $@:
+ @echo ${:U1 2 3:S 2 two :Q} horizontal tabulator
+ @echo ${:U1 2 3:S 2 two :Q} space
+ @echo ${:U1 2 3:S!2!two!:Q} exclamation mark
+ @echo ${:U1 2 3:S"2"two":Q} double quotes
+ # In shell command lines, the hash does not need to be escaped.
+ # It needs to be escaped in variable assignment lines though.
+ @echo ${:U1 2 3:S#2#two#:Q} hash
+ @echo ${:U1 2 3:S$2$two$:Q} dollar
+ @echo ${:U1 2 3:S%2%two%:Q} percent
+ @echo ${:U1 2 3:S'2'two':Q} apostrophe
+ @echo ${:U1 2 3:S(2(two(:Q} opening parenthesis
+ @echo ${:U1 2 3:S)2)two):Q} closing parenthesis
+ @echo ${:U1 2 3:S121two1:Q} digit
+ @echo ${:U1 2 3:S:2:two::Q} colon
+ @echo ${:U1 2 3:S<2<two<:Q} less than sign
+ @echo ${:U1 2 3:S=2=two=:Q} equal sign
+ @echo ${:U1 2 3:S>2>two>:Q} greater than sign
+ @echo ${:U1 2 3:S?2?two?:Q} question mark
+ @echo ${:U1 2 3:S@2@two@:Q} at
+ @echo ${:U1 2 3:Sa2atwoa:Q} letter
+ @echo ${:U1 2 3:S[2[two[:Q} opening bracket
+ @echo ${:U1 2 3:S\2\two\:Q} backslash
+ @echo ${:U1 2 3:S]2]two]:Q} closing bracket
+ @echo ${:U1 2 3:S^2^two^:Q} caret
+ @echo ${:U1 2 3:S{2{two{:Q} opening brace
+ @echo ${:U1 2 3:S|2|two|:Q} vertical line
+ @echo ${:U1 2 3:S}2}two}:Q} closing brace
+ @echo ${:U1 2 3:S~2~two~:Q} tilde
+
# The :S and :C modifiers can be chained without a separating ':'.
# This is not documented in the manual page.
# It works because ApplyModifier_Subst scans for the known modifiers g1W
Home |
Main Index |
Thread Index |
Old Index