DORMANTno replies

[PATCH] Avoid broken Solaris tr

From: Ben Walton <hidden>
Date: 2016-06-15 22:57:49
Subsystem: the rest · Maintainer: Linus Torvalds

Solaris' tr (both /usr/bin/ and /usr/xpg4/bin) fail to handle the case
where the first argument is a multi-character set and the second is a
single null character. Use perl to perform these substitutions
instead. Now that we're using perl for the transliteration, we might
as well replace the sed invocations with it too.

We make this change globally in t0008-ignores instead of just for the
cases where it matters in order to maintain consistency.

Signed-off-by: Ben Walton <redacted>
---
 t/t0008-ignores.sh | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
index a56db80..9e4987e 100755
--- a/t/t0008-ignores.sh
+++ b/t/t0008-ignores.sh
@@ -552,12 +552,13 @@ cat <<-EOF >expected-verbose
 	$global_excludes:2:!globaltwo	b/globaltwo
 EOF
 
-sed -e 's/^"//' -e 's/\\//' -e 's/"$//' stdin | \
-	tr "\n" "\0" >stdin0
-sed -e 's/^"//' -e 's/\\//' -e 's/"$//' expected-default | \
-	tr "\n" "\0" >expected-default0
-sed -e 's/	"/	/' -e 's/\\//' -e 's/"$//' expected-verbose | \
-	tr ":\t\n" "\0" >expected-verbose0
+perl -pne 's/^"//; s/\\//; s/"$//; s/\n/\0/g' stdin >stdin0
+
+perl -pne 's/^"//; s/\\//; s/"$//; s/\n/\0/g' expected-default > \
+    expected-default0
+
+perl -pne 's/	"/	/; s/\\//; s/"$//; s/[:\t\n]/\0/g' expected-verbose > \
+    expected-verbose0
 
 test_expect_success '--stdin' '
 	expect_from_stdin <expected-default &&
@@ -638,12 +639,13 @@ EOF
 grep -v '^::	' expected-all >expected-verbose
 sed -e 's/.*	//' expected-verbose >expected-default
 
-sed -e 's/^"//' -e 's/\\//' -e 's/"$//' stdin | \
-	tr "\n" "\0" >stdin0
-sed -e 's/^"//' -e 's/\\//' -e 's/"$//' expected-default | \
-	tr "\n" "\0" >expected-default0
-sed -e 's/	"/	/' -e 's/\\//' -e 's/"$//' expected-verbose | \
-	tr ":\t\n" "\0" >expected-verbose0
+perl -pne 's/^"//; s/\\//; s/"$//; s/\n/\0/g' stdin >stdin0
+
+perl -pne 's/^"//; s/\\//; s/"$//; s/\n/\0/g' expected-default > \
+    expected-default0
+
+perl -pne 's/	"/	/; s/\\//; s/"$//; s/[:\t\n]/\0/g' expected-verbose > \
+    expected-verbose0
 
 test_expect_success '--stdin from subdirectory' '
 	expect_from_stdin <expected-default &&
-- 
1.8.1.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help