[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