Re: [PATCH 1/2] Modify tr expression so that xpg4/tr handles it on Solaris
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")