mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 09:10:28 +00:00
sh: Fix $? in heredocs on simple commands.
PR: bin/41410
This commit is contained in:
parent
b17788c1a9
commit
b3f892d9e0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=222716
|
@ -409,6 +409,7 @@ evalsubshell(union node *n, int flags)
|
|||
struct job *jp;
|
||||
int backgnd = (n->type == NBACKGND);
|
||||
|
||||
oexitstatus = exitstatus;
|
||||
expredir(n->nredir.redirect);
|
||||
if ((!backgnd && flags & EV_EXIT && !have_traps()) ||
|
||||
forkshell(jp = makejob(n, 1), n, backgnd) == 0) {
|
||||
|
@ -436,6 +437,7 @@ evalredir(union node *n, int flags)
|
|||
struct jmploc *savehandler;
|
||||
volatile int in_redirect = 1;
|
||||
|
||||
oexitstatus = exitstatus;
|
||||
expredir(n->nredir.redirect);
|
||||
savehandler = handler;
|
||||
if (setjmp(jmploc.loc)) {
|
||||
|
@ -478,7 +480,6 @@ expredir(union node *n)
|
|||
for (redir = n ; redir ; redir = redir->nfile.next) {
|
||||
struct arglist fn;
|
||||
fn.lastp = &fn.list;
|
||||
oexitstatus = exitstatus;
|
||||
switch (redir->type) {
|
||||
case NFROM:
|
||||
case NTO:
|
||||
|
|
15
tools/regression/bin/sh/expansion/heredoc2.0
Normal file
15
tools/regression/bin/sh/expansion/heredoc2.0
Normal file
|
@ -0,0 +1,15 @@
|
|||
# $FreeBSD$
|
||||
|
||||
f() { return $1; }
|
||||
|
||||
[ `f 42; cat <<EOF
|
||||
$?
|
||||
EOF
|
||||
` = 42 ] || echo simple command bad
|
||||
|
||||
long=`printf %08192d 0`
|
||||
|
||||
[ `f 42; cat <<EOF
|
||||
$long.$?
|
||||
EOF
|
||||
` = $long.42 ] || echo long simple command bad
|
Loading…
Reference in a new issue