From: Jeff King <hidden> Date: 2016-06-15 22:44:22
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.
t/t6000lib.sh | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
@@ -97,7 +97,10 @@ check_output()# from front and back. name_from_description(){-tr"'"'-'|tr'~`!@#$%^&*()_+={}[]|\;:"<>,/? ''-'|tr-s'-'|tr'[A-Z]''[a-z]'|sed"s/^-*//;s/-*\$//"+tr"'"'-'|+tr'~`!@#$%^&*()_+={}[]|\;:"<>,/? '\+'------------------------------'|+tr-s'-'|tr'[A-Z]''[a-z]'|sed"s/^-*//;s/-*\$//"}
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(-)
From: Jeff King <hidden> Date: 2016-06-15 22:44:23
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.
-Peff
On Fri, Mar 14, 2008 at 03:47:37PM -0500, Brandon Casey wrote:
quoted
If the dashdash notation is not portable, then
backslashing each dash also works. i.e. '\-\-\-\-..
I wonder if there are
systems that will get confused about it being a range.
Oh, now I understand _why_ backslashing the dashes worked. When your
email arrived I was still trying to figure out why
echo hello | tr aeiou '\-\-\-\-\-'
correctly converted the e and o into dashes. Because tr must have a
way for the user to escape the range notation. I don't use tr very
often.
-brandon
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 <redacted>
---
Jeff King wrote:
On Fri, Mar 14, 2008 at 03:47:37PM -0500, Brandon Casey wrote:
quoted
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(-)
From: Jeff King <hidden> Date: 2016-06-15 22:44:23
On Fri, Mar 14, 2008 at 04:26:31PM -0500, Brandon Casey wrote:
Here's the version with escaped dashes. If you do the sed version, it's
something to compare to for readability.
[...]
- '------------------------------' |
+ '\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-' |
Ugh. How about:
sed 'yA~`!@#$%^&*()_+={}[]|\;:"<>,/? A------------------------------A'
The 'A' delimiter is because in my test, Solaris sed didn't seem to
understand \/ to include the literal '/'. And all of the other
punctuation is already used in the pattern. ;)
-Peff
On Fri, Mar 14, 2008 at 04:26:31PM -0500, Brandon Casey wrote:
quoted
Here's the version with escaped dashes. If you do the sed version, it's
something to compare to for readability.
[...]
- '------------------------------' |
+ '\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-' |
Ugh. How about:
sed 'yA~`!@#$%^&*()_+={}[]|\;:"<>,/? A------------------------------A'
Not working. I get:
* ok 33: bisection diff --bisect u5 ^U <= 0
sed: -e expression #1, char 64: unterminated `y' command
* FAIL 34: --bisect l5 ^root
check_output "git rev-list $_bisect_option l5 ^root"
sed: -e expression #1, char 64: unterminated `y' command
* FAIL 35: --bisect l5 ^root ^c3
check_output "git rev-list $_bisect_option l5 ^root ^c3"
sed: -e expression #1, char 64: unterminated `y' command
* FAIL 36: --bisect l5 ^root ^c3 ^b4
But this does:
sed 'yA~`!@#$%^&*()_+={}\[]|\\;:"<>,/? A------------------------------A'
I have to escape open bracket and backslash on my end (linux). :(
Have to leave now, so if that doesn't work for you (which I'm thinking it
won't), I won't be able to test on my end for a while.
-brandon