summaryrefslogtreecommitdiff
path: root/lib/CPAN/HandleConfig.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CPAN/HandleConfig.pm')
-rw-r--r--lib/CPAN/HandleConfig.pm80
1 files changed, 73 insertions, 7 deletions
diff --git a/lib/CPAN/HandleConfig.pm b/lib/CPAN/HandleConfig.pm
index 93e2a9c3f3..588b15bbc0 100644
--- a/lib/CPAN/HandleConfig.pm
+++ b/lib/CPAN/HandleConfig.pm
@@ -2,7 +2,7 @@ package CPAN::HandleConfig;
use strict;
use vars qw(%can %keys $VERSION);
-$VERSION = sprintf "%.6f", substr(q$Rev: 657 $,4)/1000000 + 5.4;
+$VERSION = sprintf "%.6f", substr(q$Rev: 740 $,4)/1000000 + 5.4;
%can = (
commit => "Commit changes to disk",
@@ -12,10 +12,12 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 657 $,4)/1000000 + 5.4;
);
%keys = map { $_ => undef } (
+ # allow_unauthenticated ?? some day...
"build_cache",
"build_dir",
"bzip2",
"cache_metadata",
+ "check_sigs",
"commandnumber_in_prompt",
"cpan_home",
"curl",
@@ -48,6 +50,7 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 657 $,4)/1000000 + 5.4;
"ncftpget",
"no_proxy",
"pager",
+ "password",
"prefer_installer",
"prerequisites_policy",
"scan_cache",
@@ -55,8 +58,10 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 657 $,4)/1000000 + 5.4;
"show_upload_date",
"tar",
"term_is_latin",
+ "term_ornaments",
"unzip",
"urllist",
+ "username",
"wait_list",
"wget",
);
@@ -272,6 +277,59 @@ sub defaults {
1;
}
+=head2 C<< CLASS->safe_quote ITEM >>
+
+Quotes an item to become safe against spaces
+in shell interpolation. An item is enclosed
+in double quotes if:
+
+ - the item contains spaces in the middle
+ - the item does not start with a quote
+
+This happens to avoid shell interpolation
+problems when whitespace is present in
+directory names.
+
+This method uses C<commands_quote> to determine
+the correct quote. If C<commands_quote> is
+a space, no quoting will take place.
+
+
+if it starts and ends with the same quote character: leave it as it is
+
+if it contains no whitespace: leave it as it is
+
+if it contains whitespace, then
+
+if it contains quotes: better leave it as it is
+
+else: quote it with the correct quote type for the box we're on
+
+=cut
+
+{
+ # Instead of patching the guess, set commands_quote
+ # to the right value
+ my ($quotes,$use_quote)
+ = $^O eq 'MSWin32'
+ ? ('"', '"')
+ : (q<"'>, "'")
+ ;
+
+ sub safe_quote {
+ my ($self, $command) = @_;
+ # Set up quote/default quote
+ my $quote = $CPAN::Config->{commands_quote} || $quotes;
+
+ if ($quote ne ' '
+ and $command =~ /\s/
+ and $command !~ /[$quote]/) {
+ return qq<$use_quote$command$use_quote>
+ }
+ return $command;
+ }
+}
+
sub init {
my($self,@args) = @_;
undef $CPAN::Config->{'inhibit_startup_message'}; # lazy trick to
@@ -319,8 +377,16 @@ sub require_myconfig_or_config () {
my $home = home();
unshift @INC, File::Spec->catdir($home,'.cpan');
eval { require CPAN::MyConfig };
+ my $err_myconfig = $@;
+ if ($err_myconfig and $err_myconfig !~ m#locate CPAN/MyConfig\.pm#) {
+ die "Error while requiring CPAN::MyConfig:\n$err_myconfig";
+ }
unless ($INC{"CPAN/MyConfig.pm"}) { # this guy has settled his needs already
eval {require CPAN::Config;}; # not everybody has one
+ my $err_config = $@;
+ if ($err_config and $err_config !~ m#locate CPAN/Config\.pm#) {
+ die "Error while requiring CPAN::Config:\n$err_config";
+ }
}
}
@@ -401,12 +467,12 @@ sub missing_config_data {
"cache_metadata",
"cpan_home",
"ftp_proxy",
- "gzip",
+ #"gzip",
"http_proxy",
"index_expire",
"inhibit_startup_message",
"keep_source_where",
- "make",
+ #"make",
"make_arg",
"make_install_arg",
"makepl_arg",
@@ -415,11 +481,11 @@ sub missing_config_data {
"mbuild_install_build_command",
"mbuildpl_arg",
"no_proxy",
- "pager",
+ #"pager",
"prerequisites_policy",
"scan_cache",
- "tar",
- "unzip",
+ #"tar",
+ #"unzip",
"urllist",
) {
next unless exists $keys{$_};
@@ -486,7 +552,7 @@ package
use strict;
use vars qw($AUTOLOAD $VERSION);
-$VERSION = sprintf "%.2f", substr(q$Rev: 657 $,4)/100;
+$VERSION = sprintf "%.2f", substr(q$Rev: 740 $,4)/100;
# formerly CPAN::HandleConfig was known as CPAN::Config
sub AUTOLOAD {