Dear Maintainer,
The bug is triggered if the caller uses a STDIN callback that accesses a
package or lexical array variable in the caller.
Please see demonstration script and console session, below.
David
2014-05-03 12:51:49 dpchrist@dev ~/sandbox/perl
$ cat IPC-Run-run_stdin-callback-return-array.t
#! /usr/bin/perl
# $Id: IPC-Run-run_stdin-callback-return-array.t,v 1.4 2014-05-03
19:51:47 dpchrist Exp $
# Demonstrate Perl IPC::Run stdin callback problem returning array
# by David Paul Christensen dpchr...@holgerdanske.com
# Public Domain
use strict;
use warnings;
use IPC::Run qw( run );
use Test::More tests => 8;
my @cmd = ("true");
our ($i, @i);
my ($in, @in);
ok( run( \@cmd ) == 1, "no callback"); # 1
ok (run( \@cmd, sub { return undef }) == 1, "undef"); # 2
ok (run( \@cmd, sub { return "" }) == 1, "empty string"); # 3
ok (run( \@cmd, sub { return () }) == 1, "empty array"); # 4
ok (run( \@cmd, sub { return $i }) == 1, "package scalar"); # 5
ok (run( \@cmd, sub { return $in }) == 1, "lexical scalar"); # 6
ok (run( \@cmd, sub { return @i }) == 1, "package array"); # 7
ok (run( \@cmd, sub { return @in }) == 1, "lexical array"); # 8
2014-05-03 12:51:51 dpchrist@dev ~/sandbox/perl
$ perl IPC-Run-run_stdin-callback-return-array.t
1..8
ok 1 - no callback
ok 2 - undef
ok 3 - empty string
ok 4 - empty array
ok 5 - package scalar
ok 6 - lexical scalar
2014-05-03 12:51:53 dpchrist@dev ~/sandbox/perl
$ perl -d IPC-Run-run_stdin-callback-return-array.t
Loading DB routines from perl5db.pl version 1.33
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
1..8
main::(IPC-Run-run_stdin-callback-return-array.t:13):
13: my @cmd = ("true");
DB<1> b IPC::Run::_write
DB<2> c
ok 1 - no callback
ok 2 - undef
ok 3 - empty string
ok 4 - empty array
ok 5 - package scalar
ok 6 - lexical scalar
IPC::Run::_write(/usr/share/perl5/IPC/Run.pm:1412):
1412: confess 'undef' unless defined $_[0] && defined $_[1];
DB<2> n
IPC::Run::_write(/usr/share/perl5/IPC/Run.pm:1413):
1413: my $r = POSIX::write( $_[0], $_[1], length $_[1] );
DB<2> x @_
0 11
1 0
DB<3> c
2014-05-03 12:52:09 dpchrist@dev ~/sandbox/perl
$
--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org