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)$/i) {
last SHELLCOMMAND;
} elsif (s/\\$//s) {
chomp;
$continuation = $_;
$prompt = " > ";
} elsif (/^\!/) {
s/^\!//;
my($eval) = $_;
package CPAN::Eval;
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)
};
_unredirect;
if ($@) {
my $err = "$@";
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
CPAN::Shell->failed($CPAN::CurrentCommandId,1);
}
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);
=4= |