File Coverage

blib/lib/App/Rakubrew/Shell/Bash.pm
Criterion Covered Total %
statement 36 60 60.0
branch 3 8 37.5
condition 2 9 22.2
subroutine 11 18 61.1
pod 0 9 0.0
total 52 104 50.0


line stmt bran cond sub pod time code
1             package App::Rakubrew::Shell::Bash;
2 12     12   93 use App::Rakubrew::Shell;
  12         24  
  12         888  
3             our @ISA = "App::Rakubrew::Shell";
4 12     12   90 use strict;
  12         24  
  12         487  
5 12     12   63 use warnings;
  12         24  
  12         871  
6 12     12   240 use 5.010;
  12         42  
7              
8 12     12   87 use Encode::Locale qw(env);
  12         19  
  12         957  
9              
10 12     12   68 use App::Rakubrew::Variables;
  12         65  
  12         2620  
11 12     12   81 use App::Rakubrew::Tools;
  12         25  
  12         1078  
12 12     12   65 use App::Rakubrew::VersionHandling;
  12         41  
  12         2159  
13 12     12   726 use App::Rakubrew::Build;
  12         28  
  12         9038  
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 1625 my $text = <
22             Load $brew_name automatically in `bash` by adding
23              
24             eval "\$($brew_exec init Bash)"
25              
26             to ~/.bashrc. This can be easily done using:
27              
28             echo 'eval "\$($brew_exec init Bash)"' >> ~/.bashrc
29             EOT
30              
31 1 50       7 if ($prefix =~ / /) {
32 0         0 $text .= <
33              
34             =================================== WARNING ==================================
35              
36             rakubrews home directory is currently
37              
38             $prefix
39              
40             That folder contains spaces. This will break building rakudos as the build
41             system currently doesn't work in such a path. You can work around this problem
42             by changing that folder to a directory without spaces. Do so by putting
43              
44             export RAKUBREW_HOME=/some/folder/without/space/rakubrew
45              
46             in your `~/.bashrc` file *before* the `eval` line.
47             EOW
48             }
49 1         384 return $text;
50             }
51              
52             sub get_init_code {
53 1     1 0 2 my $self = shift;
54 1         5 my $path = env('PATH');
55 1         222 $path = $self->clean_path($path);
56 1 50       6 if (get_brew_mode() eq 'env') {
57 1         4 my $version = get_global_version();
58 1 50 33     9 if ($version && $version ne 'system' && !is_version_broken($version)) {
      33        
59 0           $path = join(':', get_bin_paths($version), $path);
60             }
61             }
62             else { # get_brew_mode() eq 'shim'
63 0           $path = join(':', $shim_dir, $path);
64             }
65 1           return <
66             export PATH="$path"
67             $brew_name() {
68             command $brew_exec internal_hooked Bash "\$@" &&
69             eval "`command $brew_exec internal_shell_hook Bash post_call_eval "\$@"`"
70             }
71             _${brew_name}_completions() {
72             COMPREPLY=(\$(command $brew_exec internal_shell_hook Bash completions \$COMP_CWORD \$COMP_LINE))
73             \$(command $brew_exec internal_shell_hook Bash completion_options \$COMP_CWORD \$COMP_LINE)
74             }
75             complete -F _${brew_name}_completions $brew_name
76             EOT
77             }
78              
79             sub post_call_eval {
80 0     0 0   my $self = shift;
81 0           $self->print_shellmod_code(@_);
82             }
83              
84             sub get_path_setter_code {
85 0     0 0   my $self = shift;
86 0           my $path = shift;
87 0           return "export PATH=\"$path\"";
88             }
89              
90             sub get_shell_setter_code {
91 0     0 0   my $self = shift;
92 0           my $version = shift;
93 0           return "export $env_var=\"$version\"";
94             }
95              
96             sub get_shell_unsetter_code {
97 0     0 0   my $self = shift;
98 0           return "unset $env_var";
99             }
100              
101             sub completions {
102 0     0 0   my $self = shift;
103 0           my $index = shift;
104 0           say join(' ', $self->get_completions($self->strip_executable($index, @_)));
105             }
106              
107             sub completion_options {
108 0     0 0   my $self = shift;
109 0           my $index = shift;
110 0           my @words = @_;
111              
112 0 0 0       if($index == 3 && $words[1] eq 'register') {
113 0           say 'compopt -o nospace';
114             }
115             else {
116 0           say '';
117             }
118             }
119              
120             1;
121