Subject: | Test for wget or curl doesn't handle all result code values |
This is perl 5, version 12, subversion 2 (v5.12.2) built for sun4-solaris
SunOS cfindexprod5-a 5.10 Generic_127111-05 sun4u sparc
I get the following error when executing `perlbrew available` or any
other perlbrew command that requires downloading using wget or curl:
sh: curl: not found
Can't exec "curl": No such file or directory at
/home/nypntdev/iprs_perl/lib/perl5/App/perlbrew.pm line 198.
open() for 'curl --silent --location --fail --insecure
http://www.cpan.org/src/README.html': No such file or directory at
/home/nypntdev/iprs_perl/lib/perl5/App/perlbrew.pm line 198.
When checking to see if curl or wget is available, the test applied is this:
if ($code != 127) {
However, at least on my version of Solaris, the status code returned by
system has a value of 1. The Perl docs for system() suggest the simple
test to check for a status code of 0 to indicate success or failure.
perlbrew assumes that if this test passes, then curl (in this case) is
working properly, and then tries to open the downloaded content, which
doesn't exist.
The attached patch file fixes this problem, though it is somewhat
simpler, it is also more comprehensive in that it considers all options.
Subject: | perlbrew.patch |
--- perlbrew.pm-orig Fri Oct 28 11:57:02 2011
+++ perlbrew.pm Fri Oct 28 12:19:48 2011
@@ -186,7 +186,7 @@
for my $command (@commands) {
my $program = $command->[0];
my $code = system("$program --version >/dev/null 2>&1") >> 8;
- if ($code != 127) {
+ if ($code == 0) {
@command = @$command;
last;
}