Mailing List Archive

t/run/locale.t: new STDERR warning
A test recently added to t/run/locale.t is producing noise on STDERR when
building perl on my system.

The test is (in part):

local $ENV{LC_ALL} = "This is not a legal locale name";

fresh_perl_like("", qr/Falling back to the $fallback locale/,
{}, "check that illegal startup environment falls back");

and it produces this output:

$ ./perl -Ilib t/run/locale.t > /dev/null
sh: warning: setlocale: LC_ALL: cannot change locale (This is not a legal locale name): No such file or directory
$

Should this be silenced?

--
Never work with children, animals, or actors.
Re: t/run/locale.t: new STDERR warning [ In reply to ]
On 10/12/22 05:50, Dave Mitchell wrote:
> A test recently added to t/run/locale.t is producing noise on STDERR when
> building perl on my system.
>
> The test is (in part):
>
> local $ENV{LC_ALL} = "This is not a legal locale name";
>
> fresh_perl_like("", qr/Falling back to the $fallback locale/,
> {}, "check that illegal startup environment falls back");
>
> and it produces this output:
>
> $ ./perl -Ilib t/run/locale.t > /dev/null
> sh: warning: setlocale: LC_ALL: cannot change locale (This is not a legal locale name): No such file or directory
> $
>
> Should this be silenced?
>

Yes, but I don't know a good way to do so. It is coming from the shell;
not all shells raise it. For some shells, LC_ALL and friends are
significant, and changing them to a locale not present on the system
causes the shell to complain. But that is the point of the test, to
make sure that perl properly handles
Re: t/run/locale.t: new STDERR warning [ In reply to ]
On 10/12/22 07:50, Dave Mitchell wrote:
> A test recently added to t/run/locale.t is producing noise on STDERR when
> building perl on my system.
>
> The test is (in part):
>
> local $ENV{LC_ALL} = "This is not a legal locale name";
>
> fresh_perl_like("", qr/Falling back to the $fallback locale/,
> {}, "check that illegal startup environment falls back");
>
> and it produces this output:
>
> $ ./perl -Ilib t/run/locale.t > /dev/null
> sh: warning: setlocale: LC_ALL: cannot change locale (This is not a legal locale name): No such file or directory
> $

Which OS? Which shell(s)?
Re: t/run/locale.t: new STDERR warning [ In reply to ]
On 11/1/22 19:06, James E Keenan wrote:
> On 10/12/22 07:50, Dave Mitchell wrote:
>> A test recently added to  t/run/locale.t is producing noise on STDERR
>> when
>> building perl on my system.
>>
>> The test is (in part):
>>
>>      local $ENV{LC_ALL} = "This is not a legal locale name";
>>
>>      fresh_perl_like("", qr/Falling back to the $fallback locale/,
>>                      {}, "check that illegal startup environment falls
>> back");
>>
>> and it produces this output:
>>
>> $ ./perl -Ilib  t/run/locale.t > /dev/null
>> sh: warning: setlocale: LC_ALL: cannot change locale (This is not a
>> legal locale name): No such file or directory
>> $
>
> Which OS?  Which shell(s)?
>

I don't know. Next time I see it, I'll respond
Re: t/run/locale.t: new STDERR warning [ In reply to ]
On Tue, Nov 08, 2022 at 09:39:26AM -0700, Karl Williamson wrote:
> > Which OS?? Which shell(s)?
> >
>
> I don't know. Next time I see it, I'll respond

For me, it's Linux (Fedora 35), with

$ ls -l /bin/sh
lrwxrwxrwx. 1 root root 4 Sep 27 16:01 /bin/sh -> bash

$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)

I can reduce the test file to:

$ENV{LC_ALL} = "XYZ";
require './t/test.pl';
fresh_perl_like("", qr/failed/, {}, "boo");

and then further to

$ENV{LC_ALL} = "XYZ";
$r = `./perl -e "1" 2>&1`;

the backticks is what fresh_perl_like() is doing roughly, except that the
code to execute is -e1 rather than an empty file. The double quotes around
the "1" are necessary for some reason. With that code I get

$ p ~/tmp/locale.t
sh: warning: setlocale: LC_ALL: cannot change locale (XYZ): No such file or directory
$

Presumably this is because the backticks are running the command via a
shell rather than directly. I'm not sure why the quotes are necessary to
trigger that - I'd have thought the presence of 2>&1 would be enough to
count as metacharacters.

Perhaps setting LC_ALL within a called perl which itself calls perl would
do the trick, i.e. something like

fresh_perl_like(q($ENV{LC_ALL} = "XYZ"; system "$^X -e1"),
qr/failed/, {}, "boo");

--
It's not that I'm afraid to die, I just don't want to be there when it
happens.
-- Woody Allen
Re: t/run/locale.t: new STDERR warning [ In reply to ]
On 11/9/22 04:07, Dave Mitchell wrote:
> On Tue, Nov 08, 2022 at 09:39:26AM -0700, Karl Williamson wrote:
>>> Which OS?  Which shell(s)?
>>>
>>
>> I don't know. Next time I see it, I'll respond
>
> For me, it's Linux (Fedora 35), with
>
> $ ls -l /bin/sh
> lrwxrwxrwx. 1 root root 4 Sep 27 16:01 /bin/sh -> bash
>
> $ bash --version
> GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)
>
> I can reduce the test file to:
>
> $ENV{LC_ALL} = "XYZ";
> require './t/test.pl';
> fresh_perl_like("", qr/failed/, {}, "boo");
>
> and then further to
>
> $ENV{LC_ALL} = "XYZ";
> $r = `./perl -e "1" 2>&1`;
>
> the backticks is what fresh_perl_like() is doing roughly, except that the
> code to execute is -e1 rather than an empty file. The double quotes around
> the "1" are necessary for some reason. With that code I get
>
> $ p ~/tmp/locale.t
> sh: warning: setlocale: LC_ALL: cannot change locale (XYZ): No such file or directory
> $
>
> Presumably this is because the backticks are running the command via a
> shell rather than directly. I'm not sure why the quotes are necessary to
> trigger that - I'd have thought the presence of 2>&1 would be enough to
> count as metacharacters.
>
> Perhaps setting LC_ALL within a called perl which itself calls perl would
> do the trick, i.e. something like
>
> fresh_perl_like(q($ENV{LC_ALL} = "XYZ"; system "$^X -e1"),
> qr/failed/, {}, "boo");
>

I thought I used to be able to reproduce this, but cannot now. Is this
still happening?
Re: t/run/locale.t: new STDERR warning [ In reply to ]
On Wed, Apr 19, 2023 at 02:05:33PM -0600, Karl Williamson wrote:
> I thought I used to be able to reproduce this, but cannot now. Is this
> still happening?

Still happens for me on today's blead:

$ cat /tmp/locale.t
$ENV{LC_ALL} = "XYZ";
$r = `./perl -e "1" 2>&1`;

$ ./perl /tmp/locale.t
sh: warning: setlocale: LC_ALL: cannot change locale (XYZ): No such file or directory
$


--
This is a great day for France!
-- Nixon at Charles De Gaulle's funeral