]> Sergey Matveev's repositories - public-inbox.git/commitdiff
spawn: which: allow embedded slash for relative path
authorEric Wong <e@80x24.org>
Fri, 15 Nov 2019 09:50:42 +0000 (09:50 +0000)
committerEric Wong <e@80x24.org>
Sat, 16 Nov 2019 11:05:23 +0000 (11:05 +0000)
This makes the subroutine behave more like which(1) command
and will make using spawn() in tests easier.

lib/PublicInbox/Spawn.pm

index e2868a559741b2416cdbba9960bf598434577c08..b946a66373b84faedaef1a71d02329a2cf8587fe 100644 (file)
@@ -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;