Subject: | cpanp with options does not work when shell is set |
I like the classic CPAN interface so I use CPANPLUS::Shell::Classic with CPANPLUS. I was trying to use cpanp script with command-line options to execute commands. I kept having weird problems and tracked them down that the script was using the configured shell. The options are the correct commands for the Default shell but the Classic shell uses completely
The solution is to use the Default shell if there are any command-line options. I have included a patch that fixes this problem by passing the shell type 'Default' to the CPANPLUS::shell function when there are any command-line options.
I found a second bug that causes the CPANPLUS::shell to not use the shell passed as a parameter. The problem is that CPANPLUS::Shell::Default has at the top:
use CPANPLUS::Shell;
This calls CPANPLUS::Shell::import('CPANPLUS::Shell'). This forces using the configured shell instead of the parameter shell.
--- bin/cpanp.orig 2003-09-27 18:10:45.000000000 -0700
+++ bin/cpanp 2003-09-27 18:29:11.000000000 -0700
@@ -95,7 +95,15 @@
# special case: 'o' and 'b' may take zero arguments
@cmd_stack = $opt if !@cmd_stack and $opt =~ /^[ob]$/;
+my $shell_type;
+
if (@cmd_stack) {
+
+ $shell_type = 'Default';
+
+ warn "Type: $shell_type\n";
+ warn join("\n", @cmd_stack), "\n";
+
# initializes configure setup if we've not been through it yet
no strict 'refs';
@@ -135,7 +143,7 @@
*{'CPANPLUS::Shell::_Faked::parse_options'} = \&CPANPLUS::Tools::Term::parse_options;
}
-shell();
+shell($shell_type);
1;
--- lib/CPANPLUS/Shell/Default.pm.orig 2003-09-27 18:32:44.000000000 -0700
+++ lib/CPANPLUS/Shell/Default.pm 2003-09-27 18:39:04.000000000 -0700
@@ -22,7 +22,7 @@
$VERSION = '0.03';
}
-use CPANPLUS::Shell;
+use CPANPLUS::Shell ();
use CPANPLUS::Backend;
use CPANPLUS::I18N;
use CPANPLUS::Tools::Term;