Psh/Strategy/Bang.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 29 CC 3 SCAR 14.6
CC
3
Cov
0%
applies
6.0
execute
6.0
consumes
2.0
CRAP 4.3
1 package Psh::Strategy::Bang;
2  
3 require Psh::Strategy;
4  
5  
6 =item * C<bang>
7  
8 If the input line starts with ! all remaining input will be
9 sent unchanged to /bin/sh
10  
11 =cut
12  
13  
14 @Psh::Strategy::Bang::ISA=('Psh::Strategy');
15  
16 sub consumes {
17 return Psh::Strategy::CONSUME_LINE;
18 }
19  
20 sub runs_before {
21 return qw(brace);
22 }
23  
24 sub applies {
25 return 'pass to sh' if substr(${$_[1]},0,1) eq '!';
26 }
27  
28 sub execute {
29 my $command= substr(${$_[1]},1);
30  
31 my $fgflag = 1;
32 if ($command =~ /^(.*)\&\s*$/) {
33 $command= $1;
34 $fgflag=0;
35 }
36  
37 Psh::OS::fork_process( $command, $fgflag, $command, 1);
38 return (1,undef);
39 }
40  
41 1;