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

[PATCH] t/t6000lib.sh: tr portability fix fix

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Mar 14, 2008, 21:26 UTC
Message-ID
<47DAED87.1000408@nrlssc.navy.mil>
In-Reply-To
<20080314205415.GA17728@coredump.intra.peff.net>

Some versions of tr have a problem with character sets which begin with multiple dashes and attempt to interpret them as long options. Escape each dash to avoid this confusion and also prevent a possible interpretation of the dashes as a range.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
Jeff King wrote:
Show 11 quoted lines
> On Fri, Mar 14, 2008 at 03:47:37PM -0500, Brandon Casey wrote:
> 
>> This patch fixes things. If the dashdash notation is not portable, then
>> backslashing each dash also works. i.e. '\-\-\-\-.. etc. but as you
>> mentioned something like that is less readable, but possibly not as bad
>> as a sed version.
> 
> It seems to work fine on Solaris with all versions of tr. I did just
> blindly extend the '-' without thinking, though...I wonder if there are
> systems that will get confused about it being a range. It might be
> safer to just use sed anyway.

Here's the version with escaped dashes. If you do the sed version, it's something to compare to for readability.

-brandon
 t/t6000lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t6000lib.sh b/t/t6000lib.sh
index b69f7c4..71f2140 100755
--- a/t/t6000lib.sh
+++ b/t/t6000lib.sh
@@ -99,7 +99,7 @@ name_from_description()
 {
         tr "'" '-' |
 		tr '~`!@#$%^&*()_+={}[]|\;:"<>,/? ' \
-		   '------------------------------' |
+		   '\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-' |
 		tr -s '-' | tr '[A-Z]' '[a-z]' | sed "s/^-*//;s/-*\$//"
 }
 
-- 
1.5.4.4.481.g5075
Previous: Brandon CaseyNext: Jeff King
Message 34 of 59 in “tr portability fixes”
  1. 01/16 tr portability fixesJeff King, Mar 12, 2008
  2. Johannes SixtMar 13, 2008
  3. Jeff KingMar 13, 2008
  4. 02/16 t0050: perl portability fixJeff King, Mar 12, 2008
  5. Johannes SixtMar 13, 2008
  6. 03/16 more tr portability test script fixesJeff King, Mar 12, 2008
  7. Frank LichtenheldMar 13, 2008
  8. Jeff KingMar 13, 2008
  9. Alex RiesenMar 18, 2008
  10. Add test-tr: poor-man tr for the test suiteAlex Riesen, Mar 18, 2008
  11. Use test-tr in the test suiteAlex Riesen, Mar 18, 2008
  12. Jeff KingMar 18, 2008
  13. Alex RiesenMar 18, 2008
  14. Junio C HamanoMar 19, 2008
  15. Alex RiesenMar 19, 2008
  16. 04/16 grep portability fix: don't use "-e" or "-q"Jeff King, Mar 12, 2008
  17. Junio C HamanoMar 12, 2008
  18. Junio C HamanoMar 12, 2008
  19. 05/16 remove use of "tail -n 1" and "tail -1"Jeff King, Mar 12, 2008
  20. 06/16 add test_cmp function for test scriptsJeff King, Mar 12, 2008
  21. Junio C HamanoMar 12, 2008
  22. Jeff KingMar 13, 2008
  23. Junio C HamanoMar 13, 2008
  24. 07/16 t4020: don't use grep -aJeff King, Mar 12, 2008
  25. 08/16 t4200: use cut instead of sedJeff King, Mar 12, 2008
  26. Junio C HamanoMar 13, 2008
  27. Jeff KingMar 13, 2008
  28. Junio C HamanoMar 13, 2008
  29. Jeff KingMar 14, 2008
  30. 09/16 t6000lib: tr portability fixJeff King, Mar 12, 2008
  31. t/t6000lib.sh: tr portability fix fixBrandon Casey, Mar 14, 2008
  32. Jeff KingMar 14, 2008
  33. Brandon CaseyMar 14, 2008
  34. t/t6000lib.sh: tr portability fix fixBrandon Casey, Mar 14, 2008
  35. Jeff KingMar 14, 2008
  36. Brandon CaseyMar 14, 2008
  37. 10/16 add NO_EXTERNAL_GREP build optionJeff King, Mar 12, 2008
  38. Junio C HamanoMar 12, 2008
  39. Jeff KingMar 13, 2008
  40. Johannes SixtMar 13, 2008
  41. Jeff KingMar 13, 2008
  42. Johannes SixtMar 13, 2008
  43. Jeff KingMar 13, 2008
  44. Johannes SixtMar 13, 2008
  45. Junio C HamanoMar 13, 2008
  46. 11/16 config: add --literal-match optionJeff King, Mar 12, 2008
  47. Jakub NarebskiMar 12, 2008
  48. Jeff KingMar 13, 2008
  49. Junio C HamanoMar 12, 2008
  50. Jeff KingMar 13, 2008
  51. 12/16 git-submodule: avoid sed input with no newlineJeff King, Mar 12, 2008
  52. Junio C HamanoMar 12, 2008
  53. Jeff KingMar 13, 2008
  54. 13/16 filter-branch: don't use xargs -0Jeff King, Mar 12, 2008
  55. 14/16 filter-branch: use $SHELL_PATH instead of 'sh'Jeff King, Mar 12, 2008
  56. 15/16 t9112: add missing #!/bin/sh headerJeff King, Mar 12, 2008
  57. 16/16 t7505: use SHELL_PATH in hookJeff King, Mar 12, 2008
  58. Adam PiatyszekMar 13, 2008
  59. Jeff KingMar 13, 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.