Skip to content

Commit

Permalink
Merge branch 'release/0.73'
Browse files Browse the repository at this point in the history
  • Loading branch information
gugod committed Feb 1, 2015
2 parents 60f01fc + 877f03c commit 3baea90
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 163 deletions.
8 changes: 8 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.73: # 2015-02-01T09:59:45+0100
- fixes and improvements from Manuel Streuhofer, Aristotle Pagaltzis, Sebastian Willert, David Hand, Eric Enns,
Peter Roberts, Thomas Sibley, Ivan Baidakou, thanks!
- fix 'perlbrew user' for fish users https://github.com/gugod/App-perlbrew/pull/429
- fix sub-shell for bash users https://github.com/gugod/App-perlbrew/pull/435
- clarify the 'perlbrew use' output: https://github.com/gugod/App-perlbrew/issues/439


0.72: # 2014-10-27T21:38:19+0100
- Fix 0.71 breakage on MacOSX when the shell is bash or zsh
- Fix spelling mistake. by @gregoa++
Expand Down
32 changes: 22 additions & 10 deletions bin/perlbrew
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ status are not populated back.
=head1 COMMAND: ENV
Usage: perlbrew env <name>
Usage: perlbrew env [ <name> ]
Low-level command. Invoke this command to see the list of environment
variables that are set by C<perlbrew> itself for shell integration.
Expand All @@ -444,7 +444,7 @@ tcsh / csh users should see 'setenv' statements instead of `export`.
=head1 COMMAND: SYMLINK-EXECUTABLES
Usage: perlbrew symlink-executables <name>
Usage: perlbrew symlink-executables [ <name> ]
Low-level command. This command is used to create the C<perl> executable
symbolic link to, say, C<perl5.13.6>. This is only required for
Expand Down Expand Up @@ -526,7 +526,7 @@ Show the version of perlbrew.
=head1 COMMAND: LIB
Usage:
Usage: perlbrew lib <action> <lib-name>
perlbrew lib list
perlbrew lib create <lib-name>
Expand All @@ -542,21 +542,33 @@ full name, prefixed by a perl installation name and a '@' sign, for example,
Here are some a brief examples to invoke the `lib` command:
# Create libs by name
perlbrew lib create nobita
# Create lib perl-5.12.3@shizuka
perlbrew lib create perl-5.12.3@shizuka
perlbrew list # See the list of use/switch targets.
# Create lib perl-5.14.2@nobita and perl-5.14.2@shizuka
perlbrew use perl-5.14.2
perlbrew lib create nobita
perlbrew lib create shizuka
# Activate a lib in current shell.
perlbrew use perl-5.12.3@nobita
# See the list of use/switch targets
perlbrew list
# Activate a lib in current shell
perlbrew use perl-5.12.3@shizuka
perlbrew use perl-5.14.2@nobita
perlbrew use perl-5.14.2@shizuka
# Activate a lib as default.
# Activate a lib as default
perlbrew switch perl-5.12.3@shizuka
perlbrew switch perl-5.14.2@nobita
perlbrew switch perl-5.14.2@shizuka
# Delete the lib
# Delete lib perl-5.14.2@nobita and perl-5.14.2@shizuka
perlbrew use perl-5.14.2
perlbrew lib delete nobita
perlbrew lib delete shizuka
# Delete lib perl-5.12.3@shizuka
perlbrew lib delete perl-5.12.3@shizuka
Short lib names are local to current perl. A lib name 'nobita' can refer to
Expand Down
101 changes: 33 additions & 68 deletions lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package App::perlbrew;
use strict;
use warnings;
use 5.008;
our $VERSION = "0.72";
our $VERSION = "0.73";
use Config;

BEGIN {
Expand Down Expand Up @@ -443,7 +443,7 @@ sub env {
sub path_with_tilde {
my ($self, $dir) = @_;
my $home = $self->env('HOME');
$dir =~ s/^\Q$home\E/~/ if $home;
$dir =~ s!\Q$home/\E!~/! if $home;
return $dir;
}

Expand Down Expand Up @@ -555,7 +555,7 @@ sub run_command_version {
}

sub run_command_help {
my ($self, $status, $verbose) = @_;
my ($self, $status, $verbose, $return_text) = @_;

require Pod::Usage;

Expand All @@ -581,6 +581,7 @@ sub run_command_help {
$out = "Cannot find documentation for '$status'\n\n";
}

return "\n$out" if ($return_text);
print "\n$out";
close $fh;
}
Expand Down Expand Up @@ -1700,9 +1701,6 @@ WARNINGONMAC

}
}
elsif ($shell =~ /\/bash$/) {
$shell_opt = "--noprofile --norc";
}

my %env = ($self->perlbrew_env($name), PERLBREW_SKIP_INIT => 1);

Expand Down Expand Up @@ -1732,6 +1730,7 @@ sub run_command_use {

if ( !$perl ) {
my $current = $self->current_perl;
$current .= '@' . $self->current_lib if ($self->current_lib);
if ($current) {
print "Currently using $current\n";
} else {
Expand All @@ -1749,6 +1748,7 @@ sub run_command_switch {

unless ( $dist ) {
my $current = $self->current_perl;
$current .= '@' . $self->current_lib if ($self->current_lib);
printf "Currently switched %s\n",
( $current ? "to $current" : 'off' );
return;
Expand Down Expand Up @@ -2040,12 +2040,15 @@ sub run_command_exec {
# return 255 for case when process was terminated with signal, in that case real exit code is useless and weird
$exit_code = 255 if $exit_code > 255;
$overall_success = 0;
print "Command terminated with non-zero status.\n" unless $self->{quiet};

print STDERR "Command [" .
join(' ', map { /\s/ ? "'$_'" : $_ } @ARGV) . # trying reverse shell escapes - quote arguments containing spaces
"] terminated with exit code $exit_code (\$? = $err) under the following perl environment:\n";
print STDERR $self->format_info_output;
unless ($self->{quiet}) {
print "Command terminated with non-zero status.\n";

print STDERR "Command [" .
join(' ', map { /\s/ ? "'$_'" : $_ } @ARGV) . # trying reverse shell escapes - quote arguments containing spaces
"] terminated with exit code $exit_code (\$? = $err) under the following perl environment:\n";
print STDERR $self->format_info_output;
}

$self->do_exit_with_error_code($exit_code) if ($opts{'halt-on-error'});
}
Expand Down Expand Up @@ -2076,18 +2079,9 @@ sub run_command_clean {
sub run_command_alias {
my ($self, $cmd, $name, $alias) = @_;

if (!$cmd) {
print <<USAGE;
Usage: perlbrew alias [-f] <action> <name> [<alias>]
perlbrew alias create <name> <alias>
perlbrew alias delete <alias>
perlbrew alias rename <old_alias> <new_alias>
USAGE

return;
unless($cmd) {
$self->run_command_help("alias");
exit(-1);
}

my $path_name = joinpath($self->root, "perls", $name);
Expand Down Expand Up @@ -2150,29 +2144,12 @@ sub run_command_display_installation_failure_message {
my ($self) = @_;
}

sub lib_usage {
my $usage = <<'USAGE';
Usage: perlbrew lib <action> <name> [<name> <name> ...]
perlbrew lib list
perlbrew lib create nobita
perlbrew lib create perl-5.14.2@nobita
perlbrew use perl-5.14.2@nobita
perlbrew lib delete perl-5.12.3@nobita shizuka
USAGE


return $usage;
}

sub run_command_lib {
my ($self, $subcommand, @args) = @_;

unless ($subcommand) {
print lib_usage;
return;
$self->run_command_help("lib");
exit(-1);
}

my $sub = "run_command_lib_$subcommand";
Expand All @@ -2187,7 +2164,7 @@ sub run_command_lib {
sub run_command_lib_create {
my ($self, $name) = @_;

die "ERROR: No lib name\n", lib_usage unless $name;
die "ERROR: No lib name\n", $self->run_command_help("lib", undef, 'return_text') unless $name;

$name =~ s/^/@/ unless $name =~ /@/;

Expand Down Expand Up @@ -2216,7 +2193,7 @@ sub run_command_lib_create {
sub run_command_lib_delete {
my ($self, $name) = @_;

die "ERROR: No lib to delete\n", lib_usage unless $name;
die "ERROR: No lib to delete\n", $self->run_command_help("lib", undef, 'return_text') unless $name;

$name =~ s/^/@/ unless $name =~ /@/;

Expand Down Expand Up @@ -2443,13 +2420,8 @@ __perlbrew_reinit() {
__perlbrew_purify () {
local path patharray outsep
if [[ -n "$BASH_VERSION" ]]; then
IFS=: read -ra patharray <<< "$1"
fi
if [[ -n "$ZSH_VERSION" ]]; then
IFS=: read -rA patharray <<< "$1"
fi
for path in ${patharray[@]} ; do
IFS=: read -r${BASH_VERSION+a}${ZSH_VERSION+A} patharray <<< "$1"
for path in "${patharray[@]}" ; do
case "$path" in
(*"$PERLBREW_HOME"*) ;;
(*"$PERLBREW_ROOT"*) ;;
Expand All @@ -2459,8 +2431,8 @@ __perlbrew_purify () {
}
__perlbrew_set_path () {
export MANPATH=$PERLBREW_MANPATH${PERLBREW_MANPATH:+:}$(__perlbrew_purify "$(manpath)")
export PATH=${PERLBREW_PATH:-$PERLBREW_ROOT/bin}:$(__perlbrew_purify $PATH)
export MANPATH=$PERLBREW_MANPATH${PERLBREW_MANPATH:+:}$(__perlbrew_purify "$(manpath 2>/dev/null)")
export PATH=${PERLBREW_PATH:-$PERLBREW_ROOT/bin}:$(__perlbrew_purify "$PATH")
hash -r
}
Expand All @@ -2471,12 +2443,7 @@ __perlbrew_set_env() {
}
__perlbrew_activate() {
if [[ -n "$BASH_VERSION" ]]; then
[[ $(type -t perl) == alias ]] && unalias perl 2> /dev/null
fi
if [[ -n "$ZSH_VERSION" ]]; then
[[ -n $(alias perl 2>/dev/null) ]] && unalias perl 2>/dev/null
fi
[[ -n $(alias perl 2>/dev/null) ]] && unalias perl 2>/dev/null
if [[ -n "$PERLBREW_PERL" ]]; then
__perlbrew_set_env "$PERLBREW_PERL${PERLBREW_LIB:+@}$PERLBREW_LIB"
Expand Down Expand Up @@ -2507,11 +2474,9 @@ perlbrew () {
case $1 in
(use)
if [[ -z "$2" ]] ; then
if [[ -z "$PERLBREW_PERL" ]] ; then
echo "Currently using system perl"
else
echo "Currently using $PERLBREW_PERL"
fi
echo -n "Currently using ${PERLBREW_PERL:-system perl}"
[ -n "$PERLBREW_LIB" ] && echo -n "@$PERLBREW_LIB"
echo
else
__perlbrew_set_env "$2"
exit_status="$?"
Expand Down Expand Up @@ -2627,7 +2592,7 @@ function __perlbrew_set_path
end
function __perlbrew_set_env
set -l code (eval $perlbrew_command env $argv | perl -pe 's/export\s+(\S+)="(\S*)"/set -x $1 $2;/g; y/:/ /')
set -l code (eval $perlbrew_command env $argv | perl -pe 's/^(export|setenv)/set -xg/; s/^unset[env]*/set -eug/; s/$/;/; y/:/ /')
if test -z "$code"
return 0;
Expand Down Expand Up @@ -2705,7 +2670,7 @@ function perlbrew
end
function __source_init
perl -pe's/^export/set -x/; s/=/ /; s/$/;/;' "$PERLBREW_HOME/init" | . -
perl -pe's/^\(export|setenv\)/set -xg/; s/=/ /; s/$/;/;' "$PERLBREW_HOME/init" | . -
end
if test -z "$PERLBREW_ROOT"
Expand Down Expand Up @@ -3074,7 +3039,7 @@ Kang-min Liu C<< <gugod@gugod.org> >>
=head1 COPYRIGHT
Copyright (c) 2010,2011,2012,2013,2014 Kang-min Liu C<< <gugod@gugod.org> >>.
Copyright (c) 2010,2011,2012,2013,2014,2015 Kang-min Liu C<< <gugod@gugod.org> >>.
=head1 LICENCE
Expand Down
Loading

0 comments on commit 3baea90

Please sign in to comment.