Thread (7 messages) flat view 7 messages, 2 authors, 2016-06-15
DORMANTno replies

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

From: Brandon Casey <hidden>
Date: 2016-06-15 22:44:23
Subsystem: the rest · Maintainer: Linus Torvalds

Some versions of tr have a problem with character sets which begin with
multiple dashes and attempt to interpret them as long options. Use the
'--' notation to signal the end of command line options.

Signed-off-by: Brandon Casey <redacted>
---


Jeff King wrote:
Some versions of tr complain if the number of characters in
both sets isn't the same. So here we must manually expand
the dashes in set2.

Signed-off-by: Jeff King <redacted>
---
This almost makes me want to just use sed instead. But quoting that line
noise would probably make it less readable.
I get the following error on t6002-rev-list-bisect.sh:

*   ok 31: bisection diff --bisect u3 ^U <= 0
*   ok 32: bisection diff --bisect u4 ^U <= 0
*   ok 33: bisection diff --bisect u5 ^U <= 0
tr: unrecognized option `------------------------------'
Try `tr --help' for more information.
* FAIL 34: --bisect l5 ^root
        check_output  "git rev-list $_bisect_option l5 ^root"
tr: unrecognized option `------------------------------'
Try `tr --help' for more information.
* FAIL 35: --bisect l5 ^root ^c3
...


This is tr version 5.2.1.

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.

-brandon


 t/t6000lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t6000lib.sh b/t/t6000lib.sh
index b69f7c4..aac6a31 100755
--- a/t/t6000lib.sh
+++ b/t/t6000lib.sh
@@ -98,7 +98,7 @@ check_output()
 name_from_description()
 {
         tr "'" '-' |
-		tr '~`!@#$%^&*()_+={}[]|\;:"<>,/? ' \
+		tr -- '~`!@#$%^&*()_+={}[]|\;:"<>,/? ' \
 		   '------------------------------' |
 		tr -s '-' | tr '[A-Z]' '[a-z]' | sed "s/^-*//;s/-*\$//"
 }
-- 
1.5.4.4.481.g5075
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help