Ok, so I realize $^W = 1 or its sister, running with she-bang: #!/usr/bin/perl -w is no longer good style. But we have legacy code that does that. And with that, run \@cmd, '>pty>' causes a warning as this demo will show.
Feel free to summarily close it if you think:
This is the submitter's own damn fault. Don't use $^W=1 or perl -w
#!/usr/bin/perl -w
# Yeah, one shouldn't use 'perl -w' or $^W=1 but some of our legacy code does.
$^W=1;
use strict;
use IPC::Run qw( run start finish );
# Like this or only in the child as done below:
#
# $SIG{__WARN__} = sub {
# die "Dying because of warning: " . $_[0];
# };
my $outAndErr = '';
{
# This neutralizes the "perl -w" above, and if enabled, the warning goes away
# local $^W = 0;
run(
['echo', 'hello world'],
'>pty>',
\$outAndErr,
init => sub {
$SIG{__WARN__} = sub {
die "Dying because of child warning: " . $_[0];
};
}
);
}
print $outAndErr;
Running this yields:
> ./ipc.pl
Dying because of child warning: Filehandle STDIN reopened as $s1 only for output at /usr/share/perl5/IPC/Run.pm line 2623.
at ./ipc.pl line 27.
> perl -MIPC::Run -E 'say $IPC::Run::VERSION'
20180523.0
> perl -V | head -n 1
Summary of my perl5 (revision 5 version 24 subversion 1) configuration
Ok, so I realize
$^W = 1
or its sister, running with she-bang:#!/usr/bin/perl -w
is no longer good style. But we have legacy code that does that. And with that,run \@cmd, '>pty>'
causes a warning as this demo will show.Feel free to summarily close it if you think:
Running this yields:
(Also tried it on perl 5.20 with the same result)