Skip to content

Commit

Permalink
Add constructor option fixed_paths
Browse files Browse the repository at this point in the history
The name indicates that it will remain the same despite changes to
`$ENV{PATH}`.
  • Loading branch information
zmughal committed Oct 15, 2022
1 parent 482c625 commit c0c44b2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/File/Which.pm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ sub new {

$self->{PATHEXT} = $self->_default_pathext;

if( exists $opts{fixed_paths} ) {
$self->{fixed_paths} = $opts{fixed_paths};
}

$self;
}

Expand Down Expand Up @@ -249,7 +253,9 @@ sub which {
return $exec ## no critic (ValuesAndExpressions::ProhibitMixedBooleanOperators)
if !$self->_is_vms and !$self->_is_mac and !$self->_is_win and $exec =~ /\// and -f $exec and -x $exec;

my @path = @{ $self->_default_path };
my @path = exists $self->{fixed_paths}
? @{ $self->{fixed_paths} }
: @{ $self->_default_path };

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

0 comments on commit c0c44b2

Please sign in to comment.