Skip to content

Commit

Permalink
Move use of implicit_current_dir after getting path
Browse files Browse the repository at this point in the history
This is so that it applied even if using `fixed_paths`.
  • Loading branch information
zmughal committed Oct 15, 2022
1 parent f5d5a31 commit bdb1461
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/File/Which.pm
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ sub _default_path {
} else {
@path = File::Spec->path;
}
if ( $self->{implicit_current_dir} ) {
unshift @path, File::Spec->curdir;
}
\@path;
}

Expand Down Expand Up @@ -257,6 +254,12 @@ sub which {
? @{ $self->{fixed_paths} }
: @{ $self->_default_path };

# implicit_current_dir is added after getting the paths
# so that changes in the $CWD are applied
if ( $self->{implicit_current_dir} ) {
unshift @path, File::Spec->curdir;
}

my @PATHEXT = @{ $self->{PATHEXT} };
foreach my $base ( map { File::Spec->catfile($_, $exec) } @path ) {
for my $ext ( @PATHEXT ) {
Expand Down

0 comments on commit bdb1461

Please sign in to comment.