File Coverage

blib/lib/App/Rakubrew/Shell/Sh.pm
Criterion Covered Total %
statement 29 51 56.8
branch 1 6 16.6
condition 0 6 0.0
subroutine 10 16 62.5
pod 0 7 0.0
total 40 86 46.5


line stmt bran cond sub pod time code
1             package App::Rakubrew::Shell::Sh;
2 1     1   14 use App::Rakubrew::Shell;
  1         3  
  1         181  
3             our @ISA = "App::Rakubrew::Shell";
4 1     1   11 use strict;
  1         3  
  1         88  
5 1     1   10 use warnings;
  1         3  
  1         135  
6 1     1   110 use 5.010;
  1         62  
7              
8 1     1   12 use Encode::Locale qw(env);
  1         2  
  1         177  
9              
10 1     1   15 use App::Rakubrew::Variables;
  1         3  
  1         604  
11 1     1   15 use App::Rakubrew::Tools;
  1         3  
  1         163  
12 1     1   7 use App::Rakubrew::VersionHandling;
  1         2  
  1         188  
13 1     1   9 use App::Rakubrew::Build;
  1         2  
  1         835  
14              
15             sub supports_hooking {
16 0     0 0 0 my $self = shift;
17 0         0 1;
18             }
19              
20             sub install_note {
21 1     1 0 1167 my $text = <
22             Load $brew_name automatically in POSIX compatible shells (ash, dash, ksh and
23             similar) by adding
24              
25             eval "\$($brew_exec init Sh)"
26              
27             to ~/.profile.
28             This can be easily done using:
29              
30             echo 'eval "\$($brew_exec init Sh)"' >> ~/.profile
31              
32             Note that this enables rakubrew *only* in login shells.
33             To get rakubrew also working in non-login shells, you need the following:
34              
35             echo 'export ENV=~/.shrc' >> ~/.profile
36             echo 'eval "\$($brew_exec init Sh)"' >> ~/.shrc
37              
38             Make sure that `ENV` is not already set to point to some other file.
39             EOT
40              
41 1 50       52 if ($prefix =~ / /) {
42 0         0 $text .= <
43              
44             ================================ WARNING ======================================
45              
46             rakubrews home directory is currently
47              
48             $prefix
49              
50             That folder contains spaces. This will break building rakudos as the build
51             system currently doesn't work in such a path. You can work around this problem
52             by changing that folder to a directory without spaces. Do so by putting
53              
54             export RAKUBREW_HOME=/some/folder/without/space/rakubrew
55              
56             in your `~/.profile` file.
57             EOW
58             }
59 1         27 return $text;
60             }
61              
62             sub get_init_code {
63 0     0 0   my $self = shift;
64 0           my $path = env('PATH');
65 0           $path = $self->clean_path($path);
66 0 0         if (get_brew_mode() eq 'env') {
67 0           my $version = get_global_version();
68 0 0 0       if ($version && $version ne 'system' && !is_version_broken($version)) {
      0        
69 0           $path = join(':', get_bin_paths($version), $path);
70             }
71             }
72             else { # get_brew_mode() eq 'shim'
73 0           $path = join(':', $shim_dir, $path);
74             }
75              
76 0           return <
77             export PATH="$path"
78             $brew_name() {
79             command $brew_exec internal_hooked Sh "\$@" &&
80             eval "`command $brew_exec internal_shell_hook Sh post_call_eval "\$@"`"
81             }
82             EOT
83              
84             }
85              
86             sub post_call_eval {
87 0     0 0   my $self = shift;
88 0           $self->print_shellmod_code(@_);
89             }
90              
91             sub get_path_setter_code {
92 0     0 0   my $self = shift;
93 0           my $path = shift;
94 0           return "export PATH=\"$path\"";
95             }
96              
97             sub get_shell_setter_code {
98 0     0 0   my $self = shift;
99 0           my $version = shift;
100 0           return "export $env_var=\"$version\"";
101             }
102              
103             sub get_shell_unsetter_code {
104 0     0 0   my $self = shift;
105 0           return "unset $env_var";
106             }
107              
108             1;
109