1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-26 16:18:31 +00:00

Support the remaining job ID formats required by SUSv3:

%+ (current job, same as %%),
%- (previous job),
%?str (job with "str" in its command name).
This commit is contained in:
Tim J. Robbins 2002-06-01 01:51:42 +00:00
parent 27d72beba7
commit f63d6dbfc9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97688

View File

@ -518,7 +518,7 @@ STATIC struct job *
getjob(char *name)
{
int jobno;
struct job *jp;
struct job *found, *jp;
int pid;
int i;
@ -539,9 +539,28 @@ currentjob: if ((jp = getcurjob(NULL)) == NULL)
#if JOBS
} else if (name[1] == '%' && name[2] == '\0') {
goto currentjob;
} else if (name[1] == '+' && name[2] == '\0') {
goto currentjob;
} else if (name[1] == '-' && name[2] == '\0') {
if ((jp = getcurjob(NULL)) == NULL ||
(jp = getcurjob(jp)) == NULL)
error("No previous job");
return (jp);
#endif
} else if (name[1] == '?') {
found = NULL;
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
if (jp->used && jp->nprocs > 0
&& strstr(jp->ps[0].cmd, name + 2) != NULL) {
if (found)
error("%s: ambiguous", name);
found = jp;
}
}
if (found != NULL)
return (found);
} else {
struct job *found = NULL;
found = NULL;
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
if (jp->used && jp->nprocs > 0
&& prefix(name + 1, jp->ps[0].cmd)) {