Skip to content

Commit

Permalink
Check that the executable found is a file
Browse files Browse the repository at this point in the history
This prevents false positives with directories earlier in PATH.

Closes #511.
  • Loading branch information
cbvi authored and AlexDaniel committed May 3, 2020
1 parent f32210a commit 6bb8710
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core.c/Main.pm6
Expand Up @@ -110,7 +110,8 @@ my sub RUN-MAIN(&main, $mainline, :$in-as-argsfiles) {
my ($vol, $dir, $base) = $SPEC.splitpath($name);
$dir = $SPEC.canonpath($dir);
for $SPEC.path() -> $elem {
if $SPEC.catpath($vol, $elem, $base).IO.x {
my $file = $SPEC.catpath($vol, $elem, $base).IO;
if $file.x && $file.f {
return $base if $SPEC.canonpath($elem) eq $dir;
# Shadowed command found in earlier PATH element
return $name;
Expand Down

0 comments on commit 6bb8710

Please sign in to comment.