Subject: | find_file() magic doesn't find files magically |
The find_file() magic doesn't work when the script is started with a full path:
$ /usr/local/bin/mymagic
Will not find /etc/mymagic.config
This patch makes it work...
--- lib/Config/Auto.pm.orig Mon Feb 9 11:42:31 2004
+++ lib/Config/Auto.pm Mon Feb 9 11:47:41 2004
@@ -3,6 +3,7 @@
use strict;
use warnings;
use File::Spec::Functions;
+use File::Basename;
#use XML::Simple; # this is now optional
use Config::IniFiles;
use Carp;
@@ -129,10 +130,12 @@
sub find_file {
my $x;
- my $whoami = $0;
+ my $whoami = basename($0);
+ my $bindir = dirname($0);
$whoami =~ s/\.pl$//;
for ("${whoami}config", "${whoami}.config", "${whoami}rc", ".${whoami}rc") {
return $_ if -e $_;
+ return $x if -e ($x=catfile($bindir,$_));
return $x if -e ($x=catfile($ENV{HOME},$_));
return "/etc/$_" if -e "/etc/$_";
}