mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-21 09:13:37 +00:00
sh: Recognize "--" as end of options in bg/fg/jobid builtins.
This commit is contained in:
parent
4fe1afd789
commit
f0ef49bbf4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=254413
|
@ -183,13 +183,14 @@ out: out2fmt_flush("sh: can't access tty; job control turned off\n");
|
|||
|
||||
#if JOBS
|
||||
int
|
||||
fgcmd(int argc __unused, char **argv)
|
||||
fgcmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
struct job *jp;
|
||||
pid_t pgrp;
|
||||
int status;
|
||||
|
||||
jp = getjob(argv[1]);
|
||||
nextopt("");
|
||||
jp = getjob(*argptr);
|
||||
if (jp->jobctl == 0)
|
||||
error("job not created under job control");
|
||||
printjobcmd(jp);
|
||||
|
@ -210,8 +211,9 @@ bgcmd(int argc, char **argv)
|
|||
{
|
||||
struct job *jp;
|
||||
|
||||
nextopt("");
|
||||
do {
|
||||
jp = getjob(*++argv);
|
||||
jp = getjob(*argptr);
|
||||
if (jp->jobctl == 0)
|
||||
error("job not created under job control");
|
||||
if (jp->state == JOBDONE)
|
||||
|
@ -220,7 +222,7 @@ bgcmd(int argc, char **argv)
|
|||
jp->foreground = 0;
|
||||
out1fmt("[%td] ", jp - jobtab + 1);
|
||||
printjobcmd(jp);
|
||||
} while (--argc > 1);
|
||||
} while (*argptr != NULL && *++argptr != NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -542,12 +544,13 @@ waitcmdloop(struct job *job)
|
|||
|
||||
|
||||
int
|
||||
jobidcmd(int argc __unused, char **argv)
|
||||
jobidcmd(int argc __unused, char **argv __unused)
|
||||
{
|
||||
struct job *jp;
|
||||
int i;
|
||||
|
||||
jp = getjob(argv[1]);
|
||||
nextopt("");
|
||||
jp = getjob(*argptr);
|
||||
for (i = 0 ; i < jp->nprocs ; ) {
|
||||
out1fmt("%d", (int)jp->ps[i].pid);
|
||||
out1c(++i < jp->nprocs? ' ' : '\n');
|
||||
|
|
9
tools/regression/bin/sh/builtins/jobid2.0
Normal file
9
tools/regression/bin/sh/builtins/jobid2.0
Normal file
|
@ -0,0 +1,9 @@
|
|||
# $FreeBSD$
|
||||
|
||||
: &
|
||||
p1=$(jobid)
|
||||
p2=$(jobid --)
|
||||
p3=$(jobid %+)
|
||||
p4=$(jobid -- %+)
|
||||
[ "${p1:?}" = "${p2:?}" ] && [ "${p2:?}" = "${p3:?}" ] &&
|
||||
[ "${p3:?}" = "${p4:?}" ] && [ "${p4:?}" = "${p1:?}" ]
|
Loading…
Reference in a new issue