svn commit: r223163 - in head: bin/sh tools/regression/bin/sh/expansion

Jilles Tjoelker jilles at FreeBSD.org
Thu Jun 16 21:50:29 UTC 2011


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') ]


More information about the svn-src-head mailing list