Open
Description
It doesn't make sense for this function to return files that don't exist. Make this not happen.
This is some code I wrote that should take care of it, but I don't have time now to deal with fixing the tests and investigating the potential repercussions.
--- a/lib/App/Ack/ConfigFinder.pm
+++ b/lib/App/Ack/ConfigFinder.pm
@@ -105,26 +105,31 @@ Locates config files, and returns a list of them.
=cut
sub find_config_files {
- my @config_files;
+ my @possibles;
if ( $App::Ack::is_windows ) {
- push @config_files, map { +{ path => File::Spec->catfile($_, 'ackrc') } } (
- Win32::GetFolderPath(Win32::CSIDL_COMMON_APPDATA()),
- Win32::GetFolderPath(Win32::CSIDL_APPDATA()),
+ push( @possibles,
+ map { File::Spec->catfile( Win32::GetFolderPath($_), 'ackrc') } (
+ Win32::CSIDL_COMMON_APPDATA(),
+ Win32::CSIDL_APPDATA(),
+ )
);
}
else {
- push @config_files, { path => '/etc/ackrc' };
+ push( @possibles, '/etc/ackrc' );
}
if ( $ENV{'ACKRC'} && -f $ENV{'ACKRC'} ) {
- push @config_files, { path => $ENV{'ACKRC'} };
+ push( @possibles, $ENV{'ACKRC'} );
}
else {
- push @config_files, map { +{ path => $_ } } _check_for_ackrc($ENV{'HOME'});
+ push( @possibles, _check_for_ackrc($ENV{'HOME'}) );
}
+ my @config_files = map { +{ path => $_ } } grep { -e } @possibles;
+
+
my $cwd = Cwd::getcwd();
return () unless defined $cwd;