File Coverage

blib/lib/App/Rakubrew/Shell/Sh.pm
Criterion Covered Total %
statement 26 48 54.1
branch 1 6 16.6
condition 0 6 0.0
subroutine 9 15 60.0
pod 0 7 0.0
total 36 82 43.9


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