package Psh
::Builtins
::Jobs
;
=item * C<jobs [-rs] [-p]>
List the currently running jobs.
Option B<-r> restricts the output to display only currently running jobs.
Option B<-s> will only show currently stopped jobs
If you specify option B<-p> only the PIDs of the processes are displayed.
local @ARGV = @
{shift()};
if( ! Psh
::OS
::has_job_control
()) {
Psh
::Util
::print_error_i18n
('no_jobcontrol');
Getopt
::Std
::getopts
('prs',$opt);
Psh
::Joblist
::enumerate
();
while( ($job=Psh
::Joblist
::each())) {
my $command = $job->{call
};
next if $opt->{'r'} and !$job->{running
};
next if $opt->{'s'} and $job->{running
};
if ($opt->{'p'}) { # print pid's only
$result .= "[$visindex] $pid $command";
if ($job->{running
}) { $result .= "\n"; }
else { $result .= ' ('.Psh
::Locale
::get_text
('stopped').")\n"; }
Psh
::Util
::print_out_i18n
('bi_jobs_none');
Psh
::Util
::print_out
($result);