Date: Thu, 16 Jun 2011 21:50:28 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r223163 - in head: bin/sh tools/regression/bin/sh/expansion Message-ID: <201106162150.p5GLoSWL047177@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Thu Jun 16 21:50:28 2011 New Revision: 223163 URL: http://svn.freebsd.org/changeset/base/223163 Log: 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. Added: head/tools/regression/bin/sh/expansion/cmdsubst11.0 (contents, props changed) Modified: head/bin/sh/eval.c Modified: head/bin/sh/eval.c ============================================================================== --- head/bin/sh/eval.c Thu Jun 16 21:12:36 2011 (r223162) +++ head/bin/sh/eval.c Thu Jun 16 21:50:28 2011 (r223163) @@ -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, dup2(pip[1], 1); close(pip[1]); } + flags &= ~EV_BACKCMD; } flags |= EV_EXIT; } Added: head/tools/regression/bin/sh/expansion/cmdsubst11.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/cmdsubst11.0 Thu Jun 16 21:50:28 2011 (r223163) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +# Not required by POSIX but useful for efficiency. + +[ $$ = $(eval '${SH} -c echo\ \$PPID') ]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106162150.p5GLoSWL047177>