Skip to content

Commit

Permalink
final (?) fix for locale problem (RT #41285)
Browse files Browse the repository at this point in the history
Instead of testing the value of the env variables, use
POSIX::setlocale to get the effective value of the LC_CTYPE
locale (the only one effecting tr operation).

For the workaround on top of the script, add also LC_CTYPE
to the list of env variables explicitely set to C.

Also, setting the env variables must happen in a BEGIN{}
block, otherwise things are too late.
  • Loading branch information
eserte committed Apr 2, 2013
1 parent c3b88c9 commit b7f034a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions t/exec.t
Expand Up @@ -31,8 +31,12 @@ require "filter-util.pl" ;
use vars qw( $Inc $Perl $script ) ;

$script = '';
if (exists $ENV{LANG} and $ENV{LANG} !~ /^C|en/) { # CPAN #41285
$script = q($ENV{LANG}='C'; $ENV{LC_ALL}='C';);
if (eval {
require POSIX;
my $val = POSIX::setlocale(&POSIX::LC_CTYPE);
$val !~ m{^(C|en)}
}) { # CPAN #41285
$script = q(BEGIN { $ENV{LANG}=$ENV{LC_ALL}=$ENV{LC_CTYPE}='C'; });
}

$script .= <<'EOF' ;
Expand Down
8 changes: 6 additions & 2 deletions t/sh.t
Expand Up @@ -31,8 +31,12 @@ require "filter-util.pl" ;
use vars qw( $Inc $Perl $script ) ;

$script = '';
if (exists $ENV{LANG} and $ENV{LANG} !~ /^C|en/) { # CPAN #41285
$script = q($ENV{LANG}='C'; $ENV{LC_ALL}='C';);
if (eval {
require POSIX;
my $val = POSIX::setlocale(&POSIX::LC_CTYPE);
$val !~ m{^(C|en)}
}) { # CPAN #41285
$script = q(BEGIN { $ENV{LANG}=$ENV{LC_ALL}=$ENV{LC_CTYPE}='C'; });
}

$script .= <<"EOF" ;
Expand Down

0 comments on commit b7f034a

Please sign in to comment.