6d4f13
From be1fa8db08d1995779592880cfe156f4351a89d5 Mon Sep 17 00:00:00 2001
6d4f13
From: brian d foy <brian.d.foy@gmail.com>
6d4f13
Date: Tue, 18 Oct 2016 16:02:51 -0400
6d4f13
Subject: [PATCH] For cpan -j, make the file an absolute path
6d4f13
MIME-Version: 1.0
6d4f13
Content-Type: text/plain; charset=UTF-8
6d4f13
Content-Transfer-Encoding: 8bit
6d4f13
6d4f13
This is an additional fix for rt.cpan.org #116507.
6d4f13
Since . will not be in @INC, we can't assume we are
6d4f13
loading from the current directory (although that's
6d4f13
a very likely situation for -j). Take whatever
6d4f13
argument we get and expand it to an absolute path.
6d4f13
6d4f13
Signed-off-by: Petr Písař <ppisar@redhat.com>
6d4f13
---
6d4f13
 lib/App/Cpan.pm | 8 +++++---
6d4f13
 1 file changed, 5 insertions(+), 3 deletions(-)
6d4f13
6d4f13
diff --git a/lib/App/Cpan.pm b/lib/App/Cpan.pm
6d4f13
index 3ddcbe8..bc22cbc 100644
6d4f13
--- a/lib/App/Cpan.pm
6d4f13
+++ b/lib/App/Cpan.pm
6d4f13
@@ -289,7 +289,7 @@ use CPAN 1.80 (); # needs no test
6d4f13
 use Config;
6d4f13
 use autouse Cwd => qw(cwd);
6d4f13
 use autouse 'Data::Dumper' => qw(Dumper);
6d4f13
-use File::Spec::Functions;
6d4f13
+use File::Spec::Functions qw(catfile file_name_is_absolute rel2abs);
6d4f13
 use File::Basename;
6d4f13
 use Getopt::Std;
6d4f13
 
6d4f13
@@ -1093,12 +1093,14 @@ sub _shell
6d4f13
 
6d4f13
 sub _load_config # -j
6d4f13
 	{
6d4f13
-	my $file = shift || '';
6d4f13
+	my $argument = shift;
6d4f13
+
6d4f13
+	my $file = file_name_is_absolute( $argument ) ? $argument : rel2abs( $argument );
6d4f13
+	croak( "cpan config file [$file] for -j does not exist!\n" ) unless -e $file;
6d4f13
 
6d4f13
 	# should I clear out any existing config here?
6d4f13
 	$CPAN::Config = {};
6d4f13
 	delete $INC{'CPAN/Config.pm'};
6d4f13
-	croak( "Config file [$file] does not exist!\n" ) unless -e $file;
6d4f13
 
6d4f13
 	my $rc = eval "require '$file'";
6d4f13
 
6d4f13
-- 
6d4f13
2.13.6
6d4f13