summaryrefslogtreecommitdiffstats
path: root/bin/sh/eval.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-06-16 21:50:28 +0000
committerjilles <jilles@FreeBSD.org>2011-06-16 21:50:28 +0000
commit00d33feb9db18288f251841bbebdf3b74f4d875e (patch)
tree294e1c4d6e3e5c1512b2ca2ccbd4ef4b71e3362f /bin/sh/eval.c
parentb127ed6f91700e786b6d214b85775e125cb5688b (diff)
downloadFreeBSD-src-00d33feb9db18288f251841bbebdf3b74f4d875e.zip
FreeBSD-src-00d33feb9db18288f251841bbebdf3b74f4d875e.tar.gz
sh: Reduce unnecessary forks with eval.
The eval special builtin now runs the code with EV_EXIT if it was run with EV_EXIT itself. In particular, this eliminates one fork when a command substitution contains an eval command that ends with an external program or a subshell. This is similar to what r220978 did for functions.
Diffstat (limited to 'bin/sh/eval.c')
-rw-r--r--bin/sh/eval.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 9d67b9e..25793c1 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -140,7 +140,7 @@ evalcmd(int argc, char **argv)
STPUTC('\0', concat);
p = grabstackstr(concat);
}
- evalstring(p, builtin_flags & EV_TESTED);
+ evalstring(p, builtin_flags);
} else
exitstatus = 0;
return exitstatus;
@@ -908,6 +908,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
dup2(pip[1], 1);
close(pip[1]);
}
+ flags &= ~EV_BACKCMD;
}
flags |= EV_EXIT;
}
OpenPOWER on IntegriCloud