Psh/Builtins/Forfile.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 21 CC 1 SCAR 6.9
CC
1
Cov
0%
bi_forfile
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Psh::Builtins::Forfile;
2  
3 =item * C<forfile globpattern command>
4  
5 Comparable to the sh-for command:
6  
7 for i in globpattern; do command $i; done
8  
9 The current filename will be assigned to $_
10  
11 Examples:
12  
13 forfile *.zip unzip $_
14  
15 =cut
16  
17 require Psh::Parser;
18 require Psh;
19 require Psh::Util;
20  
21 sub bi_forfile {
22 my @words=@{$_[1]};
23 my @files= Psh::OS::glob(Psh::Parser::unquote($words[0]));
24 foreach my $file (@files) {
25 $command= join(' ',@words[1..$#words]);
26 Psh::evl("\$\_=\"$file\"; $command");
27 }
28 return (1,undef);
29 }
30  
31 1;