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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <casey@xxxxxxxxxxxxxxx>
---


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 <peff@xxxxxxxx>
> ---
> 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux