Module Name:    src
Committed By:   kre
Date:           Sat Aug 19 21:18:47 UTC 2017

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

Log Message:
Add a few more sub-tests to the $'...' syntax tests.
Remove dome debug noise accidentally left in when the test was first added.
(This still does not matter just yet, but should do soon.)


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/bin/sh/t_syntax.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_syntax.sh
diff -u src/tests/bin/sh/t_syntax.sh:1.7 src/tests/bin/sh/t_syntax.sh:1.8
--- src/tests/bin/sh/t_syntax.sh:1.7	Fri Aug 18 21:22:30 2017
+++ src/tests/bin/sh/t_syntax.sh	Sat Aug 19 21:18:47 2017
@@ -1,4 +1,4 @@
-# $NetBSD: t_syntax.sh,v 1.7 2017/08/18 21:22:30 kre Exp $
+# $NetBSD: t_syntax.sh,v 1.8 2017/08/19 21:18:47 kre Exp $
 #
 # Copyright (c) 2017 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -300,8 +300,8 @@ d_cstrings_head() {
 	atf_set "descr" "Check processing of $' ' quoting (C style strings)"
 }
 d_cstrings_body() {
-	set -xv
 	unset ENV
+
 	if ! ${TEST_SH} -c ": \$'abc'" ||
 	     test $( ${TEST_SH} -c "printf %s \$'abc'" ) != abc
 	then
@@ -335,7 +335,6 @@ d_cstrings_body() {
 	# all the \X sequences for a single char X (ie: not hex/octal/unicode)
 	atf_check -s exit:0 -e empty -o inline:'\n\r\t\n' \
 		${TEST_SH} -c "printf '%s\\n' \$'\\a\\b\\e\\f\\n\\r\\t\\v'"
-#	atf_check -s exit:0 -e empty -o inline:'\7\10\33\14\12\15\11\13' \
 	atf_check -s exit:0 -e empty -o inline:'\n\r\t\n' \
 	   ${TEST_SH} -c "printf '%s\\n' \$'\\cG\\cH\\x1b\\cl\\cJ\\cm\\cI\\ck'"
 	atf_check -s exit:0 -e empty -o inline:"'"'"\\\n' \
@@ -363,8 +362,24 @@ d_cstrings_body() {
 
 	# \newline in a $'...' is dropped (just like in "" strings)
 	atf_check -s exit:0 -e empty -o inline:'abcdef' ${TEST_SH} -c \
-		"printf '%s' \$'abc\\
+"printf '%s' \$'abc\\
+def'"
+	# but a normal newline in a $'...' is just a newline
+	atf_check -s exit:0 -e empty -o inline:'abc\ndef' ${TEST_SH} -c \
+"printf '%s' \$'abc
 def'"
+	# and should work when elided line wrap occurs between $ and '
+	atf_check -s exit:0 -e empty -o inline:'abc\ndef' ${TEST_SH} -c \
+"printf '%s' \$\\
+'abc\\ndef'"
+
+	# $'...' only works when the $ is unquoted.
+	atf_check -s exit:0 -e empty -o inline:"abc\$'def'g" ${TEST_SH} -c \
+		"printf '%s' \"abc\$'def'g\""
+	atf_check -s exit:0 -e empty -o inline:'abc$defg' ${TEST_SH} -c \
+		"printf '%s' abc\\\$'def'g"
+	atf_check -s exit:0 -e empty -o inline:'abc$def' ${TEST_SH} -c \
+		"printf '%s' abc'\$'def"
 }
 
 atf_test_case f_redirects

Reply via email to