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

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

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 19, 2015, 03:45 UTC
Message-ID
<CAPig+cQ7E5+0aZ09Bhv+j_wmBkOq9kbqUyqxTn=qVV8+j7Mbrw@mail.gmail.com>
In-Reply-To
<CAPig+cQYROsp4nsEj1cJ=W+BtxO5iQ0_UHUaJHScpN7iQBpi6A@mail.gmail.com>
On Sat, Jul 18, 2015 at 11:31 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 25 quoted lines
> On Sat, Jul 18, 2015 at 11:21 AM, Ben Walton <bdwalton@gmail.com> wrote:
>> 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.
>>
>> Signed-off-by: Ben Walton <bdwalton@gmail.com>
>> ---
>> -               ehost=$(echo $3 | tr -d "[]")
>> +               ehost=$(echo $3 | tr -d "\133\135")
>
> These octal values are somewhat opaque. To make this more
> self-documenting, would it make sense instead to define a global
> variable named 'brackets' or 'squarebrackets' (or something) and then
> reference that variable in each of the 'tr' commands?
>
>     brackets='\133\135'
>     ...
>     ehost=$(echo $3 | tr -d $brackets)
Quoted, of course:
    ehost=$(echo $3 | tr -d "$brackets")
Previous: Eric Sunshine
Message 3 of 3 in “Modify tr expression so that xpg4/tr handles it on Solaris”
  1. 1/2 Modify tr expression so that xpg4/tr handles it on SolarisBen Walton, Jul 18, 2015
  2. Eric SunshineJul 19, 2015
  3. Eric SunshineJul 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.