From: Graham Knop Date: Sat, 14 Dec 2013 19:57:49 +0000 (-0500) Subject: shelltype should be a parameter, not an attribute X-Git-Tag: v2.000_000~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=efeadddf4fbd4d74f66345688f61cfba3125db82;p=p5sagit%2Flocal-lib.git shelltype should be a parameter, not an attribute --- diff --git a/lib/local/lib.pm b/lib/local/lib.pm index 7920149..831e8b4 100644 --- a/lib/local/lib.pm +++ b/lib/local/lib.pm @@ -16,6 +16,7 @@ sub import { my @steps; my %opts; + my $shelltype; while (@args) { my $arg = shift @args; @@ -52,8 +53,7 @@ DEATH push @steps, ['deactivate_all']; } elsif ( $arg =~ /^--shelltype(?:=(.*))?$/ ) { - my $shell = defined $1 ? $1 : shift @args; - $opts{shelltype} = $shell; + $shelltype = defined $1 ? $1 : shift @args; } elsif ( $arg eq '--no-create' ) { $opts{no_create} = 1; @@ -77,7 +77,7 @@ DEATH } if ($0 eq '-') { - $self->print_environment_vars; + print $self->environment_vars_string($shelltype); exit 0; } else { @@ -334,9 +334,11 @@ sub environment_vars_string_for { $self->environment_vars_string; } sub environment_vars_string { - my $self = shift; + my ($self, $shelltype) = @_; + + $shelltype ||= $self->guess_shelltype; - my $build_method = 'build_' . $self->shelltype . '_env_declaration'; + my $build_method = "build_${shelltype}_env_declaration"; my @envs = ( PATH => $self->bins,