-# 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
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;
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";
}