diff options
author | Michael G Schwern <schwern@pobox.com> | 2005-07-11 17:00:17 -0700 |
---|---|---|
committer | Steve Hay <SteveHay@planit.com> | 2005-07-15 07:44:32 +0000 |
commit | f915a99a5a679d0552c03775d6fc6c62ff92454f (patch) | |
tree | 536283e8916c31816945b4644ce5c020a05c717f /lib/CPAN | |
parent | 3e44d7c68241d019f8f21ee22493341f4964f676 (diff) | |
download | perl-f915a99a5a679d0552c03775d6fc6c62ff92454f.tar.gz |
[perl #24691] leading spaces on cpan configuration causes failure
From: "Michael G Schwern via RT" <perlbug-followup@perl.org>
Message-ID: <rt-3.0.11-24691-116945.3.88254644317925@perl.org>
(with spaces trimmed from username too)
p4raw-id: //depot/perl@25147
Diffstat (limited to 'lib/CPAN')
-rw-r--r-- | lib/CPAN/FirstTime.pm | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/lib/CPAN/FirstTime.pm b/lib/CPAN/FirstTime.pm index 30a6c45c4e..5f9107faf1 100644 --- a/lib/CPAN/FirstTime.pm +++ b/lib/CPAN/FirstTime.pm @@ -12,7 +12,7 @@ sub url { shift->[2] } package CPAN::FirstTime; use strict; -use ExtUtils::MakeMaker qw(prompt); +use ExtUtils::MakeMaker (); use FileHandle (); use File::Basename (); use File::Path (); @@ -68,23 +68,22 @@ dialog anytime later by typing 'o conf init' at the cpan prompt.) ]; - my $manual_conf = - ExtUtils::MakeMaker::prompt("Are you ready for manual configuration?", - "yes"); + my $manual_conf = prompt("Are you ready for manual configuration?", "yes"); my $fastread; { - local $^W; - if ($manual_conf =~ /^\s*y/i) { + if ($manual_conf =~ /^y/i) { $fastread = 0; - *prompt = \&ExtUtils::MakeMaker::prompt; } else { $fastread = 1; $CPAN::Config->{urllist} ||= []; + + local $^W = 0; # prototype should match that of &MakeMaker::prompt - *prompt = sub ($;$) { + *_real_prompt = sub ($;$) { my($q,$a) = @_; my($ret) = defined $a ? $a : ""; printf qq{%s [%s]\n\n}, $q, $ret; + $ret; }; } @@ -198,8 +197,8 @@ is not available, the normal index mechanism will be used. defined($default = $CPAN::Config->{cache_metadata}) or $default = 1; do { $ans = prompt("Cache metadata (yes/no)?", ($default ? 'yes' : 'no')); - } while ($ans !~ /^\s*[yn]/i); - $CPAN::Config->{cache_metadata} = ($ans =~ /^\s*y/i ? 1 : 0); + } while ($ans !~ /^[yn]/i); + $CPAN::Config->{cache_metadata} = ($ans =~ /^y/i ? 1 : 0); # # term_is_latin @@ -222,8 +221,8 @@ will be output in UTF-8. do { $ans = prompt("Your terminal expects ISO-8859-1 (yes/no)?", ($default ? 'yes' : 'no')); - } while ($ans !~ /^\s*[yn]/i); - $CPAN::Config->{term_is_latin} = ($ans =~ /^\s*y/i ? 1 : 0); + } while ($ans !~ /^[yn]/i); + $CPAN::Config->{term_is_latin} = ($ans =~ /^y/i ? 1 : 0); # # save history in file histfile @@ -241,8 +240,6 @@ set this variable, please hit SPACE RETURN to the following question. defined($default = $CPAN::Config->{histfile}) or $default = File::Spec->catfile($CPAN::Config->{cpan_home},"histfile"); $ans = prompt("File to save your history?", $default); - $ans =~ s/^\s+//; - $ans =~ s/\s+\z//; $CPAN::Config->{histfile} = $ans; if ($CPAN::Config->{histfile}) { @@ -448,7 +445,7 @@ be echoed to the terminal! }; } - $CPAN::Config->{proxy_pass} = prompt("Your proxy password?"); + $CPAN::Config->{proxy_pass} = prompt_no_strip("Your proxy password?"); if ($CPAN::META->has_inst("Term::ReadKey")) { Term::ReadKey::ReadMode("restore"); } @@ -692,8 +689,6 @@ Please enter your CPAN site:}; $ans = prompt ($prompt, ""); if ($ans) { - $ans =~ s/^\s+//; # no leading spaces - $ans =~ s/\s+\z//; # no trailing spaces $ans =~ s|/?\z|/|; # has to end with one slash $ans = "file:$ans" unless $ans =~ /:/; # without a scheme is a file: if ($ans =~ /^\w+:\/./) { @@ -716,4 +711,28 @@ later if you\'re sure it\'s right.\n}, map { print " $_\n" } @{$CPAN::Config->{urllist}}; } + +sub _strip_spaces { + $_[0] =~ s/^\s+//; # no leading spaces + $_[0] =~ s/\s+\z//; # no trailing spaces +} + + +sub prompt ($;$) { + my $ans = _real_prompt(@_); + + _strip_spaces($ans); + + return $ans; +} + + +sub prompt_no_strip ($;$) { + return _real_prompt(@_); +} + + +*_real_prompt = \*ExtUtils::MakeMaker::prompt; + + 1; |