Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / Psh / Builtins / Fg.pm
CommitLineData
86530b38
AT
1package Psh::Builtins::Fg;
2
3require Psh::Util;
4require Psh::Joblist;
5require Psh;
6
7=item * C<fg [%JOB|COMMAND]>
8
9Bring a job into the foreground. If JOB is omitted, uses the
10highest-numbered stopped job, or, failing that, the highest-numbered job.
11JOB may either be a job number or a command. If you specify a command
12it will launch a new program (this is for consisteny with the bg command)
13
14=cut
15
16sub 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
451;