Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/bin/sh Add some tests to detect the presence of a bug ...



details:   https://anonhg.NetBSD.org/src/rev/2c638510037b
branches:  trunk
changeset: 445922:2c638510037b
user:      kre <kre%NetBSD.org@localhost>
date:      Sun Nov 18 01:24:44 2018 +0000

description:
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.)

diffstat:

 tests/bin/sh/t_patterns.sh |  11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diffs (25 lines):

diff -r a31e9e8a6dca -r 2c638510037b tests/bin/sh/t_patterns.sh
--- a/tests/bin/sh/t_patterns.sh        Sun Nov 18 01:23:57 2018 +0000
+++ b/tests/bin/sh/t_patterns.sh        Sun Nov 18 01:24:44 2018 +0000
@@ -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 @@
        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
 }
 



Home | Main Index | Thread Index | Old Index