Psh/Strategy/Executable.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 65 CC 4 SCAR 18.3
CC
4
Cov
0%
execute
12.0
applies
6.0
consumes
2.0
CRAP 6.2
1 package Psh::Strategy::Executable;
2  
3  
4 =item * C<executable>
5  
6 This strategy will search for an executable file and execute it
7 if possible.
8  
9 =cut
10  
11 require Psh::Strategy;
12 require Psh::Options;
13  
14 @Psh::Strategy::Executable::ISA=('Psh::Strategy');
15  
16 my %built_ins=();
17  
18 sub consumes {
19 return Psh::Strategy::CONSUME_TOKENS;
20 }
21  
22 sub runs_before {
23 return qw(eval);
24 }
25  
26 sub applies {
27 my $com= @{$_[2]}->[0];
28 my $executable= Psh::Util::which($com);
29 return $executable if defined $executable;
30 return '';
31 }
32  
33 sub execute {
34 my $inputline= ${$_[1]};
35 my @words= @{$_[2]};
36 my $tmp= shift @words;
37 my $executable= $_[3];
38  
39 if (Psh::Options::get_option('expansion') and
40 (!$Psh::current_options or !$Psh::current_options->{noexpand})) {
41 @words= Psh::PerlEval::variable_expansion(\@words);
42 }
43 if (Psh::Options::get_option('globbing') and
44 (!$Psh::current_options or !$Psh::current_options->{noglob})) {
45 @words = Psh::Parser::glob_expansion(\@words);
46 }
47 @words = map { Psh::Parser::unquote($_)} @words;
48  
49 return (1,join(' ',$executable,@words),[$executable,$tmp,@words], 0, undef, );
50 }
51  
52 1;