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

Re: [PATCH 1/3] Modify tr expressions so that xpg4/tr handles it on Solaris

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 19, 2015, 21:49 UTC
Message-ID
<CAPig+cSpTgcBA5YbfQWY+x+wc7rBQjugcan+MwLuZVcHaOH9kQ@mail.gmail.com>
In-Reply-To
<1437328836-19156-2-git-send-email-bdwalton@gmail.com>
On Sun, Jul 19, 2015 at 2:00 PM, Ben Walton <bdwalton@gmail.com> wrote:
Show 26 quoted lines
> It seems that xpg4/tr mishandles some strings involving [ not followed
> by a character class:
> % echo '[::1]' | /usr/xpg4/bin/tr -d '[]'
> [::1
>
> % echo '[::1]' | /usr/xpg4/bin/tr -d '['
> usr/xpg4/bin/tr: Bad string.
>
> This was breaking two tests. To fix the issue, use the octal
> representations of [ and ] instead. Reference the octal expression as
> a newly exported variable so that it's shared across tests and more
> easily understood when reading it.
>
> Signed-off-by: Ben Walton <bdwalton@gmail.com>
> ---
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 39da9c2..6b5b6cd 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -173,7 +173,10 @@ LF='
>  # when case-folding filenames
>  u200c=$(printf '\342\200\214')
>
> -export _x05 _x40 _z40 LF u200c
> +# [ and ], for use by tr commands.
> +squarebrackets="\133\135"

While it's true that the reader may be able to consult the commit message to learn more about "squarebrackets" and "tr", this might be one of those cases where either a more explanatory in-code comment is warranted or the comment should be dropped altogether, since the the current comment is not illuminating. I'd vote for expanding the comment a bit to mention "some versions of Solaris 'tr'" and a short description of the misbehavior.

Also, Hannes wondered how Solaris 'tr' would react to '[][]'. Were you able to test that or the alternative '[[]]'?

Previous: Ben WaltonNext: Ben Walton
Message 3 of 6 in “Adapt some tests to work around broken Solaris tools”
  1. Ben WaltonJul 19, 2015
  2. 1/3 Modify tr expressions so that xpg4/tr handles it on SolarisBen Walton, Jul 19, 2015
  3. Eric SunshineJul 19, 2015
  4. 2/3 Fix sed usage in tests to work around broken xpg4/sed on SolarisBen Walton, Jul 19, 2015
  5. 3/3 Fix sed usage in tests to work around broken xpg4/sed on SolarisBen Walton, Jul 19, 2015
  6. Johannes SixtJul 19, 2015

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.