The problem is the which() sub in Spawn.pm only checks if the path
fragment is executable, but this may be true of a directory as well.
In particular, a lot of people have a git directory in their $HOME
(where they store their git repos) and if $PATH contains '.' then
SpawnPP.pm will try to execute this directory leading to this failure
on a lot of lei commands:
exec ./git var GIT_PAGER failed: Permission denied at /usr/share/perl5/PublicInbox/SpawnPP.pm line 62.
fork_exec git var GIT_PAGER failed: Permission denied
As you can see what's happened is it's tried to execute my ./git
directory, which obviously fails. The fix is simple, skip executable
files which are also directories when doing $PATH based lookup
[ew: use `_' bareword to avoid 2nd stat, spelling fix in commit message]
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
return $file if index($file, '/') >= 0;
for my $p (split(/:/, $ENV{PATH})) {
$p .= "/$file";
- return $p if -x $p;
+ return $p if (-x $p && ! -d _);
}
undef;
}