develooper Front page | perl.perl5.porters | Postings from November 2022

Re: t/run/locale.t: new STDERR warning

Thread Previous | Thread Next
Dave Mitchell
November 9, 2022 11:08
Re: t/run/locale.t: new STDERR warning
Message ID:
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/';
    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
    -- Woody Allen

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About