Skip Menu |

This queue is for tickets about the System-Command CPAN distribution.

Report information
The Basics
Id: 106867
Status: resolved
Priority: 0/
Queue: System-Command

People
Owner: Nobody in particular
Requestors: justincase [...] yopmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.113



Subject: close method should return command object, not reaper
I expected to be able to do something like: my $cmd = System::Command->new(@cmd)->close; exit if 2 == ($cmd->signal // -1); but close() returns the reaper object, instead of the command object. So I have to use an extra line for the call to close(). my $cmd = System::Command->new(@cmd); $cmd->close; exit if 2 == ($cmd->signal // -1); The documentation doesn't even mention the return value of close(), so it wouldn't be breaking the api. Is the user ever going to need to make use of the reaper directly? If not, I suggest close() returns the command object. And if the reaper is to be used, it can be exposed as an attribute.
On Thu Sep 03 21:36:55 2015, justincase wrote: Show quoted text
> I expected to be able to do something like: > > my $cmd = System::Command->new(@cmd)->close; > exit if 2 == ($cmd->signal // -1); > > but close() returns the reaper object, instead of the command object. > So I have to use an extra line for the call to close(). > > my $cmd = System::Command->new(@cmd); > $cmd->close; > exit if 2 == ($cmd->signal // -1); > > The documentation doesn't even mention the return value of close(), so > it wouldn't be breaking the api.
You're not the first person to suggest that close() should return the System::Command object itself. It's something I planned for the next version. Show quoted text
> Is the user ever going to need to make use of the reaper directly? If > not, I suggest close() returns the command object. And if the reaper > is to be used, it can be exposed as an attribute.
No one should ever need to touch the reaper. It is entirely internal. Thanks for your report! -- BooK
On Thu Sep 03 22:13:40 2015, BOOK wrote: Show quoted text
> On Thu Sep 03 21:36:55 2015, justincase wrote:
> > I expected to be able to do something like: > > > > my $cmd = System::Command->new(@cmd)->close; > > exit if 2 == ($cmd->signal // -1); > > > > but close() returns the reaper object, instead of the command object. > > So I have to use an extra line for the call to close(). > > > > my $cmd = System::Command->new(@cmd); > > $cmd->close; > > exit if 2 == ($cmd->signal // -1); > > > > The documentation doesn't even mention the return value of close(), > > so > > it wouldn't be breaking the api.
> > You're not the first person to suggest that close() should return the > System::Command object itself. It's something I planned for the next > version. >
> > Is the user ever going to need to make use of the reaper directly? If > > not, I suggest close() returns the command object. And if the reaper > > is to be used, it can be exposed as an attribute.
> > No one should ever need to touch the reaper. It is entirely internal.
Actually, what you wrote would have worked if the reaper had the proper methods (it is after all the one that collects that data). So another fix for the same issue is to keep returning the reaper object, but add exit, status, etc methods to the class. With that change, your code would have worked. -- BooK