]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
spawn: get rid of wantarray popen_rd/popen_wr
authorEric Wong <e@80x24.org>
Thu, 9 Nov 2023 10:09:46 +0000 (10:09 +0000)
committerEric Wong <e@80x24.org>
Thu, 9 Nov 2023 21:53:55 +0000 (21:53 +0000)
We've updated all of our users to use Process::IO (and avoiding
tied handles) so the trade-off for using the array context
no longer exists.

lib/PublicInbox/Spawn.pm

index 8c798b3931165ce358901512daf841d085872504..8cc4dfaf7f18dd3df11fa8e0df423ea5e883a756 100644 (file)
@@ -384,16 +384,14 @@ sub spawn ($;$$) {
 sub popen_rd {
        my ($cmd, $env, $opt, @cb_arg) = @_;
        pipe(my $r, local $opt->{1});
-       my $pid = spawn($cmd, $env, $opt);
-       wantarray ? ($r, $pid) : PublicInbox::IO::attach_pid($r, $pid, @cb_arg)
+       PublicInbox::IO::attach_pid($r, spawn($cmd, $env, $opt), @cb_arg);
 }
 
 sub popen_wr {
        my ($cmd, $env, $opt, @cb_arg) = @_;
        pipe(local $opt->{0}, my $w);
        $w->autoflush(1);
-       my $pid = spawn($cmd, $env, $opt);
-       wantarray ? ($w, $pid) : PublicInbox::IO::attach_pid($w, $pid, @cb_arg)
+       PublicInbox::IO::attach_pid($w, spawn($cmd, $env, $opt), @cb_arg);
 }
 
 sub read_out_err ($) {