CPAN
view release on metacpan or search on metacpan
lib/CPAN.pm view on Meta::CPAN
}
my($continuation) = "";
my $last_term_ornaments;
SHELLCOMMAND: while () {
if ($Suppress_readline) {
if ($Echo_readline) {
$|=1;
}
print $prompt;
last SHELLCOMMAND unless defined ($_ = <> );
if ($Echo_readline) {
# backdoor: I could not find a way to record sessions
print $_;
}
chomp;
} else {
last SHELLCOMMAND unless
defined ($_ = $term->readline($prompt, $commandline));
}
$_ = "$continuation$_" if $continuation;
s/^\s+//;
next SHELLCOMMAND if /^$/;
s/^\s*\?\s*/help /;
if (/^(?:q(?:uit)?|bye|exit)\s*$/i) {
last SHELLCOMMAND;
} elsif (s/\\$//s) {
chomp;
$continuation = $_;
$prompt = " > ";
} elsif (/^\!/) {
s/^\!//;
my($eval) = $_;
package
CPAN::Eval; # hide from the indexer
use strict;
use vars qw($import_done);
CPAN->import(':DEFAULT') unless $import_done++;
CPAN->debug("eval[$eval]") if $CPAN::DEBUG;
eval($eval);
warn $@ if $@;
$continuation = "";
$prompt = $oprompt;
} elsif (/./) {
my(@line);
eval { @line = Text::ParseWords::shellwords($_) };
warn($@), next SHELLCOMMAND if $@;
warn("Text::Parsewords could not parse the line [$_]"),
next SHELLCOMMAND unless @line;
$CPAN::META->debug("line[".join("|",@line)."]") if $CPAN::DEBUG;
my $command = shift @line;
eval {
local (*STDOUT)=*STDOUT;
@line = _redirect(@line);
CPAN::Shell->$command(@line)
};
my $command_error = $@;
_unredirect;
my $reported_error;
if ($command_error) {
my $err = $command_error;
if (ref $err and $err->isa('CPAN::Exception::blocked_urllist')) {
$CPAN::Frontend->mywarn("Client not fully configured, please proceed with configuring.$err");
$reported_error = ref $err;
} else {
# I'd prefer never to arrive here and make all errors exception objects
if ($err =~ /\S/) {
require Carp;
require Dumpvalue;
my $dv = Dumpvalue->new(tick => '"');
Carp::cluck(sprintf "Catching error: %s", $dv->stringify($err));
}
}
}
if ($command =~ /^(
# classic commands
make
|test
|install
|clean
# pragmas for classic commands
|ff?orce
|notest
# compounds
|report
|smoke
|upgrade
)$/x) {
# only commands that tell us something about failed distros
# eval necessary for people without an urllist
eval {CPAN::Shell->failed($CPAN::CurrentCommandId,1);};
if (my $err = $@) {
unless (ref $err and $reported_error eq ref $err) {
die $@;
}
}
}
soft_chdir_with_alternatives(\@cwd);
$CPAN::Frontend->myprint("\n");
$continuation = "";
$CPAN::CurrentCommandId++;
$prompt = $oprompt;
}
} continue {
$commandline = ""; # I do want to be able to pass a default to
# shell, but on the second command I see no
# use in that
$Signal=0;
CPAN::Queue->nullify_queue;
if ($try_detect_readline) {
if ($CPAN::META->has_inst("Term::ReadLine::Gnu")
||
$CPAN::META->has_inst("Term::ReadLine::Perl")
) {
delete $INC{"Term/ReadLine.pm"};
my $redef = 0;
local($SIG{__WARN__}) = CPAN::Shell::paintdots_onreload(\$redef);
require Term::ReadLine;
$CPAN::Frontend->myprint("\n$redef subroutines in ".
"Term::ReadLine redefined\n");
( run in 0.586 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )