-
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
Add OO interface #41
base: main
Are you sure you want to change the base?
Add OO interface #41
Conversation
e82deae
to
77aa627
Compare
The name indicates that it will remain the same despite changes to `$ENV{PATH}`.
a9b7707
to
f534a13
Compare
sub new { | ||
my ($class, %opts) = @_; | ||
|
||
my $osname = exists $opts{os} ? $opts{os} : $^O; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure $^O
is quite right for this, it has a lot of detail for unix like operating systems and not enough for windows. I think we want to know if it is unix, or win/vms/cyg/os9, and then we want something like win+powershell win+bash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can have opts for os
and shell
. I still don't think $^O
is right for os
as Windows9x and WindowsNT are both MSWin32
unfortunately. I'm not too enthused about inventing our own categories for os, but we may have to. Note #41 (review) and #42
$self->{PATHEXT} = $self->_default_pathext; | ||
|
||
if( exists $opts{fixed_paths} ) { | ||
$self->{fixed_paths} = $opts{fixed_paths}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to delete from %opts
and error if there is anything left over, that way we can add new options in the future, and if someone is trying to use those options on an older File::Which
they will get an error.
if ( $self->_is_win ) { | ||
# WinNT. PATHEXT might be set on Cygwin, but not used. | ||
if ( $ENV{PATHEXT} ) { | ||
push @PATHEXT, split /;/, $ENV{PATHEXT}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is a Windows environment variable, but I think we should use Env qw( @PATHEXT )
for this and other list type environment variables. This will make it easier to test windows behavior on non-windows OS. Any tests that test default behavior can also use Env
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Env is core as of Perl 5, so introducing it as a prereq shouldn't be a problem.
if ( $ENV{PATHEXT} ) { | ||
push @PATHEXT, split /;/, $ENV{PATHEXT}; | ||
} else { | ||
# Win9X or other: doesn't have PATHEXT, so needs hardcoded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this isn't related to this PR, but if PATHEXT isn't supported on Windows 9x or DOS, then we shouldn't use it on those platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we should at least consider that we may need to treat DOS/Windows9x as a different OS than WindowsNT.
$self->_is_win || $self->_is_vms || $self->_is_mac; | ||
} | ||
our $IMPLICIT_CURRENT_DIR = do { | ||
File::Which->new->_default_implicit_current_dir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize for introducing this interface now. But we have to support it :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment (you are already doing that).
I think this is the right approach.
|
When you are writing the documentation, you can assume that we will bump the version to 2.00 when we add the OO interface. OO examples should look like this: use File::Which 2.00;
my $which = File::Which->new; |
DRAFT: Start of OO interface.
This PR is just a placeholder. It still needs improvements to the tests, adding
the
os_shell
option (tentative name), documentation, and setting thePATH
/PATHEXT
as options.Connects to #40.