-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: add override for @PATHEXT #40
Comments
Another way to handle this would have an option to say "sh mode" which would take these into account. It might make the calling code simpler. It's not really in keeping with the On the other hand I am tempted by your suggestion because it is less work and it is in keeping with what we have done so far. |
Perhaps this can be simplified by introducing an object that encapsulates all The object could control behaviour like # my $is_msys2 = ...;
my $which = File::Which::Object->new(
# where `File::Which::Object->default_paths` does what which()
# currently does from $ENV{PATH}
paths =>
$is_msys2
? My::Tools->mingw_paths
: File::Which::Object->default_paths,
# empty pathexts gets turned into [''] internally
# (if `allow_empty_pathext_suffix`).
# Could also have `File::Which::Object->default_pathexts`
# which does what my @PATHEXT = ... does.
pathexts => IS_WIN ? [qw(.exe .bat .com)] : [],
# do not filter out '' from pathexts
allow_empty_pathext_suffix => $is_msys2
);
my $ls = $which->which('ls');
system($ls); or have
Or maybe |
I like the idea of having an OO interface that doesn't necessarily care about the local operating system, because it will make writing regression tests possible for platforms that we can't easily or regularly test in those real environments. I think the main interface should be something like # actual names should in no way be considered final or even
# in anyway well thought out.
my $which = File::Which::Object->new( os => 'msys2_sh' ); So that the each calling code doesn't need to think about the details. I think it is fine to also have overrides for pathext etc for when you need to do that. I'm not in love with |
Sounds good! I'll take an initial go at this. |
As per discussion at PDLPorters/pdl#412 (comment) regarding finding a shell script on MSYS2/MinGW64, it might be useful to use
File::Which
's logic to find scripts that would be run bysh.exe
which do not have any suffix.This override can be similar in function to
$IMPLICIT_CURRENT_DIR
.The text was updated successfully, but these errors were encountered: