git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t6000lib: re-fix tr portability

From
Jeff King <peff@peff.net>
Date
Mar 15, 2008, 00:32 UTC
Message-ID
<20080315003233.GA29209@coredump.intra.peff.net>

It seems that some implementations of tr don't like a replacement string of '-----...'; they try to find the double-dash option "---...".

Instead of this pipeline of tr and sed invocations, just use a single perl invocation.

Signed-off-by: Jeff King <peff@peff.net>
---
I didn't see any complaints about increasing the use of perl in earlier
patches, so hopefully nobody minds. I think this is more portable, more
readable, and probably more efficient.
 t/t6000lib.sh |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/t/t6000lib.sh b/t/t6000lib.sh
index b69f7c4..c0baaa5 100755
--- a/t/t6000lib.sh
+++ b/t/t6000lib.sh
@@ -97,10 +97,13 @@ check_output()
 # from front and back.
 name_from_description()
 {
-        tr "'" '-' |
-		tr '~`!@#$%^&*()_+={}[]|\;:"<>,/? ' \
-		   '------------------------------' |
-		tr -s '-' | tr '[A-Z]' '[a-z]' | sed "s/^-*//;s/-*\$//"
+	perl -pe '
+		s/[^A-Za-z0-9.]/-/g;
+		s/-+/-/g;
+		s/-$//;
+		s/^-//;
+		y/A-Z/a-z/;
+	'
 }
 
 
-- 
1.5.4.4.686.g851d
Message 1 of 1 in “t6000lib: re-fix tr portability”
  1. t6000lib: re-fix tr portabilityJeff King, Mar 15, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.