sh: Remove special support for background simple commands.
It expands the arguments in the parent shell process, which is incorrect.
This commit is contained in:
parent
54b16435b7
commit
47e5204ee3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=223282
@ -894,14 +894,13 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fork off a child process if necessary. */
|
/* Fork off a child process if necessary. */
|
||||||
if (cmd->ncmd.backgnd
|
if (((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN)
|
||||||
|| ((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN)
|
|
||||||
&& ((flags & EV_EXIT) == 0 || have_traps()))
|
&& ((flags & EV_EXIT) == 0 || have_traps()))
|
||||||
|| ((flags & EV_BACKCMD) != 0
|
|| ((flags & EV_BACKCMD) != 0
|
||||||
&& (cmdentry.cmdtype != CMDBUILTIN ||
|
&& (cmdentry.cmdtype != CMDBUILTIN ||
|
||||||
!safe_builtin(cmdentry.u.index, argc, argv)))) {
|
!safe_builtin(cmdentry.u.index, argc, argv)))) {
|
||||||
jp = makejob(cmd, 1);
|
jp = makejob(cmd, 1);
|
||||||
mode = cmd->ncmd.backgnd;
|
mode = FORK_FG;
|
||||||
if (flags & EV_BACKCMD) {
|
if (flags & EV_BACKCMD) {
|
||||||
mode = FORK_NOJOB;
|
mode = FORK_NOJOB;
|
||||||
if (pipe(pip) < 0)
|
if (pipe(pip) < 0)
|
||||||
@ -1068,8 +1067,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
|||||||
backcmd->fd = pip[0];
|
backcmd->fd = pip[0];
|
||||||
close(pip[1]);
|
close(pip[1]);
|
||||||
backcmd->jp = jp;
|
backcmd->jp = jp;
|
||||||
} else
|
}
|
||||||
exitstatus = 0;
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (lastarg)
|
if (lastarg)
|
||||||
|
@ -56,7 +56,6 @@ NSEMI nbinary # two commands separated by a semicolon
|
|||||||
|
|
||||||
NCMD ncmd # a simple command
|
NCMD ncmd # a simple command
|
||||||
type int
|
type int
|
||||||
backgnd int # set to run command in background
|
|
||||||
args nodeptr # the arguments
|
args nodeptr # the arguments
|
||||||
redirect nodeptr # list of file redirections
|
redirect nodeptr # list of file redirections
|
||||||
|
|
||||||
|
@ -240,8 +240,8 @@ list(int nlflag, int erflag)
|
|||||||
n2 = andor();
|
n2 = andor();
|
||||||
tok = readtoken();
|
tok = readtoken();
|
||||||
if (tok == TBACKGND) {
|
if (tok == TBACKGND) {
|
||||||
if (n2->type == NCMD || n2->type == NPIPE) {
|
if (n2->type == NPIPE) {
|
||||||
n2->ncmd.backgnd = 1;
|
n2->npipe.backgnd = 1;
|
||||||
} else if (n2->type == NREDIR) {
|
} else if (n2->type == NREDIR) {
|
||||||
n2->type = NBACKGND;
|
n2->type = NBACKGND;
|
||||||
} else {
|
} else {
|
||||||
@ -689,7 +689,6 @@ simplecmd(union node **rpp, union node *redir)
|
|||||||
*rpp = NULL;
|
*rpp = NULL;
|
||||||
n = (union node *)stalloc(sizeof (struct ncmd));
|
n = (union node *)stalloc(sizeof (struct ncmd));
|
||||||
n->type = NCMD;
|
n->type = NCMD;
|
||||||
n->ncmd.backgnd = 0;
|
|
||||||
n->ncmd.args = args;
|
n->ncmd.args = args;
|
||||||
n->ncmd.redirect = redir;
|
n->ncmd.redirect = redir;
|
||||||
return n;
|
return n;
|
||||||
|
Loading…
Reference in New Issue
Block a user