Psh/Builtins/Fg.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 46 CC 7 SCAR 36.8
CC
7
Cov
0%
bi_fg
56.0
BEGIN
2.0
BEGIN
2.0
CRAP 39.8
1 package Psh::Builtins::Fg;
2  
3 require Psh::Util;
4 require Psh::Joblist;
5 require Psh;
6  
7 =item * C<fg [%JOB|COMMAND]>
8  
9 Bring a job into the foreground. If JOB is omitted, uses the
10 highest-numbered stopped job, or, failing that, the highest-numbered job.
11 JOB may either be a job number or a command. If you specify a command
12 it will launch a new program (this is for consisteny with the bg command)
13  
14 =cut
15  
16 sub bi_fg
17 {
18 my $arg = shift;
19  
20 if( ! Psh::OS::has_job_control()) {
21 Psh::Util::print_error_i18n('no_jobcontrol');
22 return (0,undef);
23 }
24  
25 if (!defined($arg) || $arg eq '') {
26 ($arg)= Psh::Joblist::find_job();
27 } else {
28 if( $arg !~ /^\%/) {
29 return Psh::evl($arg.' &');
30 }
31 $arg =~ s/\%//;
32  
33 if ( $arg !~ /^\d+$/) {
34 ($arg)= Psh::Joblist::find_last_with_name($arg,0);
35 }
36 $arg-- if defined($arg);
37 }
38 return (0,undef) unless defined($arg);
39  
40 Psh::OS::restart_job(1, $arg );
41  
42 return (1,undef);
43 }
44  
45 1;