Psh/Builtins/Function.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 24 CC 2 SCAR 13.9
CC
2
Cov
0%
bi_function
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.0
1 package Psh::Builtins::Function;
2  
3 require Psh::PerlEval;
4 require Psh::Support::Functions;
5  
6 =item * C<function>
7  
8 Function tries to emulate the functionality of bash's function builtin
9  
10 =cut
11  
12 sub bi_function
13 {
14 $_[0]=~/^\s*(\S+)\s*\{(.*)\}\s*$/s;
15 my $name=$1;
16 my $def= $2;
17 if ($name and $def) {
18 Psh::Support::Functions::add_function($name,$def);
19 Psh::PerlEval::protected_eval(qq[sub $name { Psh::Support::Functions::call_function($name); }], 'eval');
20 }
21 return (1,undef);
22 }
23  
24 1;