package CPAN::FirstTime;
use strict;
-use ExtUtils::MakeMaker qw(prompt);
+use ExtUtils::MakeMaker ();
use FileHandle ();
use File::Basename ();
use File::Path ();
];
- 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;
};
}
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
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
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}) {
};
}
- $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");
}
$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+:\/./) {
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;