Module Name:    src
Committed By:   kre
Date:           Sun Nov 18 01:24:44 UTC 2018

Modified Files:
        src/tests/bin/sh: t_patterns.sh

Log Message:
Add some tests to detect the presence of a bug in sh reported by
Martijn Dekker (private e-mail.)   Variable expansions that are
double quoted result in literal characters (nver pattern matching
meta chars.)  This includes '\' (that one was the bug.)
[On the other hand, a variable in a case pattern expansion that is
unquoted, produces a pattern, and in that the \ character can be
used to excape other pattern meta-chars (and itself.]

This addition will cause the case_matching test case to fail (two
of the newly added sub-tests fail) until fixes to /bin/sh are made.
(That is comiung soon, the code exists already.)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/bin/sh/t_patterns.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/bin/sh/t_patterns.sh
diff -u src/tests/bin/sh/t_patterns.sh:1.2 src/tests/bin/sh/t_patterns.sh:1.3
--- src/tests/bin/sh/t_patterns.sh:1.2	Fri Jul 20 18:25:56 2018
+++ src/tests/bin/sh/t_patterns.sh	Sun Nov 18 01:24:44 2018
@@ -1,4 +1,4 @@
-# $NetBSD: t_patterns.sh,v 1.2 2018/07/20 18:25:56 kre Exp $
+# $NetBSD: t_patterns.sh,v 1.3 2018/11/18 01:24:44 kre Exp $
 #
 # Copyright (c) 2018 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -671,6 +671,15 @@ case_matching_body() {
 	cf '"["' '[!][:alpha:][!]'; cf a; cm 0; cf !; cf "']'"; cm %	#256
 	cf a '[$var]' 'var="![:alpha:]"'; cm 0; cm !; cm "']'"; cm @	#261
 
+	# Next some tests of patterns containing (intended literal) '\'
+	# The first of the "set" tests pair was reported as broken bu
+	# Martijn Dekker (private mail) (Nov 2018).
+
+	cm "'\'" "'\'"							#262
+	cm "'\'" '"$var"' "var='\\'"; cf "'\'" '$var' "var='\\'"	#264
+	cm '$1' '"$2"' 'set -- \\ \\'; cf '$1' '$2' 'set -- \\ \\'	#266
+	cf '$1' '"$2"' 'set -- \\ \\\\'; cm '$1' '$2' 'set -- \\ \\\\'	#268
+
 	results
 }
 

Reply via email to