From: Eric Sunshine Date: Sun, 19 Jul 2015 03:45:11 GMT Subject: Re: [PATCH 1/2] Modify tr expression so that xpg4/tr handles it on Solaris Message-ID: In-Reply-To: On Sat, Jul 18, 2015 at 11:31 PM, Eric Sunshine wrote: > On Sat, Jul 18, 2015 at 11:21 AM, Ben Walton 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 >> --- >> - 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")