Skip to content

Commit

Permalink
deduplicate outputs of perlbrew list when PATH contain duplicated i…
Browse files Browse the repository at this point in the history
…tems.
  • Loading branch information
gugod committed Jun 5, 2011
1 parent edcae32 commit a12de67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ sub uniq(@) {
if $command[0] eq 'wget' # Exit code is 8 on 404s etc
and $? >> 8 == 8;

$cb ||= sub { return $_[0] };
return $cb->($body);
return $cb ? $cb->($body) : $body;
}
}

Expand Down Expand Up @@ -839,7 +838,7 @@ sub installed_perls {
$current_perl_executable =~ s/\n$//;

my $current_perl_executable_version;
for ( uniq grep { -f $_ && -x $_ } map { "$_/perl" } split(":", $self->env('PATH')) ) {
for ( grep { -f $_ && -x $_ } uniq map { s/\/+$//; "$_/perl" } split(":", $self->env('PATH')) ) {
$current_perl_executable_version =
$self->format_perl_version(`$_ -e 'print \$]'`);
push @result, {
Expand Down
12 changes: 10 additions & 2 deletions perlbrew
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,13 @@ sub do_install_blead {
print "Fetching $dist_git_describe as $dist_tarball_path\n";
http_get(
"http://perl5.git.perl.org/perl.git/snapshot/$dist_tarball",
undef,
sub {
my ($body) = @_;

unless ($body) {
die "\nERROR: Failed to download perl-blead tarball.\n\n";
}

open my $BALL, "> $dist_tarball_path" or die "Couldn't open $dist_tarball_path: $!";
print $BALL $body;
close $BALL;
Expand Down Expand Up @@ -623,6 +627,10 @@ sub do_install_release {
my $header = $mirror ? { 'Cookie' => "cpan=$mirror->{url}" } : undef;
my $html = http_get("http://search.cpan.org/dist/$dist", $header);

unless ($html) {
die "ERROR: Failed to download $dist tarball.";
}

my ($dist_path, $dist_tarball) =
$html =~ m[<a href="(/CPAN/authors/id/.+/(${dist}.tar.(gz|bz2)))">Download</a>];
die "ERROR: Cannot find the tarball for $dist\n"
Expand Down Expand Up @@ -832,7 +840,7 @@ sub installed_perls {
$current_perl_executable =~ s/\n$//;

my $current_perl_executable_version;
for ( uniq grep { -f $_ && -x $_ } map { "$_/perl" } split(":", $self->env('PATH')) ) {
for ( grep { -f $_ && -x $_ } uniq map { s/\/+$//; "$_/perl" } split(":", $self->env('PATH')) ) {
$current_perl_executable_version =
$self->format_perl_version(`$_ -e 'print \$]'`);
push @result, {
Expand Down

0 comments on commit a12de67

Please sign in to comment.