App-cpantimes
view release on metacpan or search on metacpan
};
# Both Win32 and Cygwin have $ENV{COMSPEC} set.
if (defined $ENV{'COMSPEC'} && $^O ne 'cygwin') {
my @shell_bin_path_parts = File::Spec->splitpath($ENV{'COMSPEC'});
$shellbin = $shell_bin_path_parts[-1];
$shelltype = do {
local $_ = $shellbin;
if(/command\.com/) {
'win32'
} elsif(/cmd\.exe/) {
'win32'
} elsif(/4nt\.exe/) {
'win32'
} else {
$shelltype
}
};
}
return $shelltype;
}
sub print_environment_vars_for {
my ($class, $path) = @_;
print $class->environment_vars_string_for($path);
}
sub environment_vars_string_for {
my ($class, $path) = @_;
my @envs = $class->build_environment_vars_for($path, LITERAL_ENV);
my $out = '';
# rather basic csh detection, goes on the assumption that something won't
# call itself csh unless it really is. also, default to bourne in the
# pathological situation where a user doesn't have $ENV{SHELL} defined.
# note also that shells with funny names, like zoid, are assumed to be
# bourne.
my $shelltype = $class->guess_shelltype;
while (@envs) {
my ($name, $value) = (shift(@envs), shift(@envs));
$value =~ s/(\\")/\\$1/g;
$out .= $class->${\"build_${shelltype}_env_declaration"}($name, $value);
}
return $out;
}
# simple routines that take two arguments: an %ENV key and a value. return
# strings that are suitable for passing directly to the relevant shell to set
# said key to said value.
sub build_bourne_env_declaration {
my $class = shift;
my($name, $value) = @_;
return qq{export ${name}="${value}"\n};
}
sub build_csh_env_declaration {
my $class = shift;
my($name, $value) = @_;
return qq{setenv ${name} "${value}"\n};
}
sub build_win32_env_declaration {
my $class = shift;
my($name, $value) = @_;
return qq{set ${name}=${value}\n};
}
sub setup_env_hash_for {
my ($class, $path) = @_;
my %envs = $class->build_environment_vars_for($path, INTERPOLATE_ENV);
@ENV{keys %envs} = values %envs;
}
sub build_environment_vars_for {
my ($class, $path, $interpolate) = @_;
return (
PERL_LOCAL_LIB_ROOT => $path,
PERL_MB_OPT => "--install_base ${path}",
PERL_MM_OPT => "INSTALL_BASE=${path}",
PERL5LIB => join($Config{path_sep},
$class->install_base_arch_path($path),
$class->install_base_perl_path($path),
(($ENV{PERL5LIB}||()) ?
($interpolate == INTERPOLATE_ENV
? ($ENV{PERL5LIB})
: (($^O ne 'MSWin32') ? '$PERL5LIB' : '%PERL5LIB%' ))
: ())
),
PATH => join($Config{path_sep},
$class->install_base_bin_path($path),
($interpolate == INTERPOLATE_ENV
? ($ENV{PATH}||())
: (($^O ne 'MSWin32') ? '$PATH' : '%PATH%' ))
),
)
}
1;
LOCAL_LIB
$fatpacked{"parent.pm"} = <<'PARENT';
package parent;
use strict;
use vars qw($VERSION);
$VERSION = '0.225';
sub import {
my $class = shift;
my $inheritor = caller(0);
if ( @_ and $_[0] eq '-norequire' ) {
shift @_;
} else {
for ( my @filename = @_ ) {
if ( $_ eq $inheritor ) {
warn "Class '$inheritor' tried to inherit from itself\n";
};
( run in 1.461 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )