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 / Bg.pm
CommitLineData
86530b38
AT
1package Psh::Builtins::Bg;
2
3require Psh::Util;
4require Psh::Joblist;
5
6=item * C<bg [%JOB|COMMAND]>
7
8Put a job into the background. If JOB is omitted, uses the
9highest-numbered stopped job, if any.
10
11If you specify a command instead of a job id it will execute
12the command in the background. You can use this if you do not
13want to type "command &".
14
15=cut
16
17sub bi_bg
18{
19 my $arg = shift;
20
21 if( ! Psh::OS::has_job_control()) {
22 Psh::Util::print_error_i18n('no_jobcontrol');
23 return (0,undef);
24 }
25
26 if (!defined($arg) || $arg eq '') {
27 ($arg)= Psh::Joblist::find_job();
28 } else {
29 if( $arg !~ /^\%/) {
30 return Psh::evl($arg.' &');
31 }
32 $arg =~ s/\%//;
33
34 if ( $arg !~ /^\d+$/) {
35 ($arg)= Psh::Joblist::find_last_with_name($arg,0);
36 }
37 $arg-- if defined($arg);
38 }
39 return (0,undef) unless defined($arg);
40
41 Psh::OS::restart_job(0, $arg);
42
43 return (1,undef);
44}
45
461;