Env-Dot
view release on metacpan or search on metacpan
lib/Env/Dot/ScriptFunctions.pm view on Meta::CPAN
return sprintf "%s=$quote%s$quote", $name, $value;
}
}
sub _convert_var_to_csh {
my ($var) = @_;
my ( $name, $value, $want_export, $allow_interpolate ) =
( $var->{'name'}, $var->{'value'}, $var->{'opts'}->{'export'}, $var->{'opts'}->{'allow_interpolate'}, );
my $quote = $allow_interpolate ? q{"} : q{'};
if ($want_export) {
return sprintf "setenv %s $quote%s$quote", $name, $value;
}
else {
return sprintf "set %s $quote%s$quote", $name, $value;
}
}
sub _convert_var_to_fish {
my ($var) = @_;
my ( $name, $value, $want_export, $allow_interpolate ) =
( $var->{'name'}, $var->{'value'}, $var->{'opts'}->{'export'}, $var->{'opts'}->{'allow_interpolate'}, );
t/env-dot-scriptfunctions.t view on Meta::CPAN
};
subtest 'Private Subroutine _convert_var_to_csh()' => sub {
{
my %var = (
name => 'THIS_VAR',
value => 'this var value',
opts => { 'export' => 1, 'allow_interpolate' => 0, },
);
my $expect = q{setenv THIS_VAR 'this var value'};
my $cmdline = Env::Dot::ScriptFunctions::_convert_var_to_csh( \%var );
is( $cmdline, $expect, 'Correct C Shell command' );
}
{
my %var = (
name => 'THIS_VAR',
value => 'this var value',
opts => { 'export' => 1, 'allow_interpolate' => 1, },
);
my $expect = q{setenv THIS_VAR "this var value"};
my $cmdline = Env::Dot::ScriptFunctions::_convert_var_to_csh( \%var );
is( $cmdline, $expect, 'Correct Bourne Shell command' );
}
{
my %var = (
name => 'THIS_VAR',
value => 'this var value',
opts => { 'export' => 0, 'allow_interpolate' => 1, },
);
( run in 0.486 second using v1.01-cache-2.11-cpan-3989ada0592 )