]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Spawn.pm
spawn: remove support for clearing the env
[public-inbox.git] / lib / PublicInbox / Spawn.pm
index 66b916dfbc72d60c28c57cdddd63a88d1b8d7966..6493ad387cdbcb915ca71fcbdc325f0ce673f768 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # This allows vfork to be used for spawning subprocesses if
@@ -178,7 +178,7 @@ unless (defined $vfork_spawn) {
 
 sub which ($) {
        my ($file) = @_;
-       return $file if index($file, '/') == 0;
+       return $file if index($file, '/') >= 0;
        foreach my $p (split(':', $ENV{PATH})) {
                $p .= "/$file";
                return $p if -x $p;
@@ -193,17 +193,7 @@ sub spawn ($;$$) {
        my @env;
        $opts ||= {};
 
-       my %env = $opts->{-env} ? () : %ENV;
-       if ($env) {
-               foreach my $k (keys %$env) {
-                       my $v = $env->{$k};
-                       if (defined $v) {
-                               $env{$k} = $v;
-                       } else {
-                               delete $env{$k};
-                       }
-               }
-       }
+       my %env = $env ? (%ENV, %$env) : %ENV;
        while (my ($k, $v) = each %env) {
                push @env, "$k=$v";
        }
@@ -229,8 +219,6 @@ sub popen_rd {
        my ($cmd, $env, $opts) = @_;
        pipe(my ($r, $w)) or die "pipe: $!\n";
        $opts ||= {};
-       my $blocking = $opts->{Blocking};
-       IO::Handle::blocking($r, $blocking) if defined $blocking;
        $opts->{1} = fileno($w);
        my $pid = spawn($cmd, $env, $opts);
        return unless defined $pid;