sh: Make expansion errors in optimized command substitution non-fatal.
Command substitutions consisting of a single simple command are executed in the main shell process but this should be invisible apart from performance and very few exceptions such as $(trap).
This commit is contained in:
parent
e29f3cc76d
commit
45b71cd16e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=216761
@ -578,6 +578,8 @@ evalbackcmd(union node *n, struct backcmd *result)
|
|||||||
int pip[2];
|
int pip[2];
|
||||||
struct job *jp;
|
struct job *jp;
|
||||||
struct stackmark smark; /* unnecessary */
|
struct stackmark smark; /* unnecessary */
|
||||||
|
struct jmploc jmploc;
|
||||||
|
struct jmploc *savehandler;
|
||||||
|
|
||||||
setstackmark(&smark);
|
setstackmark(&smark);
|
||||||
result->fd = -1;
|
result->fd = -1;
|
||||||
@ -590,7 +592,19 @@ evalbackcmd(union node *n, struct backcmd *result)
|
|||||||
}
|
}
|
||||||
if (n->type == NCMD) {
|
if (n->type == NCMD) {
|
||||||
exitstatus = oexitstatus;
|
exitstatus = oexitstatus;
|
||||||
evalcommand(n, EV_BACKCMD, result);
|
savehandler = handler;
|
||||||
|
if (setjmp(jmploc.loc)) {
|
||||||
|
if (exception == EXERROR || exception == EXEXEC)
|
||||||
|
exitstatus = 2;
|
||||||
|
else if (exception != 0) {
|
||||||
|
handler = savehandler;
|
||||||
|
longjmp(handler->loc, 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handler = &jmploc;
|
||||||
|
evalcommand(n, EV_BACKCMD, result);
|
||||||
|
}
|
||||||
|
handler = savehandler;
|
||||||
} else {
|
} else {
|
||||||
exitstatus = 0;
|
exitstatus = 0;
|
||||||
if (pipe(pip) < 0)
|
if (pipe(pip) < 0)
|
||||||
|
5
tools/regression/bin/sh/expansion/cmdsubst5.0
Normal file
5
tools/regression/bin/sh/expansion/cmdsubst5.0
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# $FreeBSD$
|
||||||
|
|
||||||
|
unset v
|
||||||
|
exec 2>/dev/null
|
||||||
|
! y=$(: ${v?})
|
Loading…
Reference in New Issue
Block a user