Subject: Re: [PATCH] t9129: fix UTF-8 locale detection

From: Yann Droneaud <[email-masked]>
Date: Wed, 19 May 2010 17:16:42 +0200

Le mardi 18 mai 2010 à 22:49 +0200, Yann Droneaud a écrit :
> Le mardi 18 mai 2010 à 10:45 -0700, Linus Torvalds a écrit :
> > 
> > On Tue, 18 May 2010, Yann Droneaud wrote:
> > >  
> > > -if locale -a |grep -q en_US.utf8; then
> > > +if locale -a |grep -qE '^en_US\.(utf|UTF)-?8$'; then
> > 
> > While -E is POSIX, I suspect that it's not universal. iirc, you still have 
> > some really crap fileutils tools coming with Solaris, for example. 
> > 
> 
> You're right, Solaris's own grep doesn't known about -E nor -e.
> 
> And it even doesn't know about -q : 
> 
>  $ grep -q                                                     
>  grep: illegal option -- q
>  Usage: grep -hblcnsviw pattern file . . .
> 

Integrating Linus's remarks and some autoconf[1][2] hints, here is a
proposal for a portable test:

   if locale -a |grep -i 'en_US\.utf-*8' > /dev/null ; then

It should be as portable as possible without too much work.

[1] egrep
<http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Usual-Tools.html#index-g_t_0040command_007begrep_007d-1706>

[2] grep
<http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Usual-Tools.html#index-g_t_0040command_007bgrep_007d-1712>

Regards.

-- 
Yann Droneaud