Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the File-Which CPAN distribution.

Report information
The Basics
Id: 102328
Status: resolved
Priority: 0/
Queue: File-Which

People
Owner: Nobody in particular
Requestors: CLEACH [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: File::Which bug if path given
Hi, I found a problem with File::Which that is causing me a headache. Where your module & Unix's "which" program behaves quite differently. The issue is when someone passes path information along with the program name. So while $p=File::Which::which("perl"); works fine and returns /usr/bin/perl as expected, $p=File::Which::which("./perl") doesn't work properly. It also returns /usr/bin/perl instead of the perl under my home directory! Should I use @p instead of $p, it shows up as the last element in the array. ("." is the final element of my Path, but if I remove "." from the path, it doesn't find the program at all, but Unix's "which" command still finds it.) When the Unix "which" command encounters a program name with a path in it, it no longer looks at the path in your environment, the program either exists or it doesn't. So the fix to your module is to assume the path is only the current directory if someone provides any path info (relative or absolute) along with the program name. I have no objections if you convert the relative path into a full absolute path or leave it relative. Curtis
Just for extra information - I checked Devel::CheckBin and it can find './perl' correctly.
Download (untitled) / with headers
text/plain 1.3k
On 2015-02-24 13:59:31, CLEACH wrote: Show quoted text
> Hi, > > I found a problem with File::Which that is causing me a headache. > Where your module & Unix's "which" program behaves quite differently. > > The issue is when someone passes path information along with the > program name. > > So while $p=File::Which::which("perl"); works fine and returns > /usr/bin/perl as expected, > > $p=File::Which::which("./perl") doesn't work properly. It also > returns /usr/bin/perl instead of the perl under my home directory! > Should I use @p instead of $p, it shows up as the last element in the > array. ("." is the final element of my Path, but if I remove "." from > the path, it doesn't find the program at all, but Unix's "which" > command still finds it.) > > When the Unix "which" command encounters a program name with a path in > it, it no longer looks at the path in your environment, the program > either exists or it doesn't. So the fix to your module is to assume > the path is only the current directory if someone provides any path > info (relative or absolute) along with the program name. > > I have no objections if you convert the relative path into a full > absolute path or leave it relative.
Variations of this bug report: * https://rt.cpan.org/Ticket/Display.html?id=102256 * https://rt.cpan.org/Ticket/Display.html?id=49559 (with patch, maybe this patch even works here)
Download (untitled) / with headers
text/plain 448b
On Tue Feb 24 14:26:33 2015, ETHER wrote: Show quoted text
> Just for extra information - I checked Devel::CheckBin and it can find > './perl' correctly.
It also would find 'perl' incorrectly: twin% perl -MDevel::CheckBin=can_run -E 'say can_run "bar"' bar twin% perl -E 'use autodie qw( :system ); system "bar"' "bar" failed to start: "No such file or directory" at (eval 5) line 12. at -e line 1 twin% perl -E 'use autodie qw( :system ); system "./bar"' twin%
Download (untitled) / with headers
text/plain 143b
This is a duplicate of rt49559. Please follow this issue on the project GitHub issue tracker: https://github.com/plicease/File-Which/issues/2


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.