IPC-Run icon indicating copy to clipboard operation
IPC-Run copied to clipboard

Behavior change for undef params in 20180523.0

Open oschwald opened this issue 6 years ago • 5 comments

Before 20180523.0, something like run([$^X], \undef, \undef, \undef, undef) or even run([$^X], \undef, undef) would run without an exception. As of the change introduced by #118, this fails with Modification of a read-only value attempted at /home/greg/MaxMind/IPC-Run/lib/IPC/Run.pm line 1686.. Changing:

@args = map { !defined $_ ? bless(\$_, 'IPC::Run::Undef') : $_ } @_;

to:

@args = map { my $v = $_; !defined $v ? bless(\$v, 'IPC::Run::Undef') : $v } @_;

fixes that particular error, but it later fails with other errors. This appears to be because the later code uses ref and length in ways incompatible with undef being replaced by IPC::Run::Undef.

oschwald avatar Jun 07 '18 22:06 oschwald

@oschwald is there a reason you can't change that to:

run([$^X])

toddr avatar Sep 24 '18 22:09 toddr

@toddr, we've worked around the particular issue, but it was a backwards incompatible behavior change not explicitly mentioned in the docs.

If I recall correctly, the reason why the code was like that is that we were conditionally passing in those params. Now we have to check whether we've passed them in.

oschwald avatar Sep 24 '18 22:09 oschwald

The whole interface is a big mess. I don't think I would make any of the existing decisions if I had to re-write it.

toddr avatar Sep 24 '18 23:09 toddr

Should we either make the docs reflect the current code, or adjust the code to match the docs?

mohawk2 avatar Sep 25 '18 02:09 mohawk2

run([$^X]) does not close the descriptors. Using \undef to close a descriptor is the most easiest way. But due to this bug, one cannot do that. This really should be documented or fixed.

ppisar avatar Feb 05 '19 13:02 ppisar