svn commit: r206944 - stable/8/bin/sh

Jilles Tjoelker jilles at FreeBSD.org
Tue Apr 20 22:32:34 UTC 2010


Author: jilles
Date: Tue Apr 20 22:32:34 2010
New Revision: 206944
URL: http://svn.freebsd.org/changeset/base/206944

Log:
  MFC r200943: sh: Remove setting variables from dotcmd/exportcmd.
  
  It is already done by evalcommand(), unless special-ness has been removed,
  in which case variable assignments should not persist. (These are currently
  always special builtins, but this may change later: command builtin,
  command substitution.)
  
  This also fixes a memory leak when calling . with variable assignments.
  
  Example:
    valgrind --leak-check=full sh -c 'x=1 . /dev/null; x=2'

Modified:
  stable/8/bin/sh/main.c
  stable/8/bin/sh/var.c
Directory Properties:
  stable/8/bin/sh/   (props changed)

Modified: stable/8/bin/sh/main.c
==============================================================================
--- stable/8/bin/sh/main.c	Tue Apr 20 22:24:35 2010	(r206943)
+++ stable/8/bin/sh/main.c	Tue Apr 20 22:32:34 2010	(r206944)
@@ -315,7 +315,6 @@ find_dot_file(char *basename)
 int
 dotcmd(int argc, char **argv)
 {
-	struct strlist *sp;
 	char *fullname;
 
 	if (argc < 2)
@@ -323,9 +322,6 @@ dotcmd(int argc, char **argv)
 
 	exitstatus = 0;
 
-	for (sp = cmdenviron; sp ; sp = sp->next)
-		setvareq(savestr(sp->text), VSTRFIXED|VTEXTFIXED);
-
 	fullname = find_dot_file(argv[1]);
 	setinputfile(fullname, 1);
 	commandname = fullname;

Modified: stable/8/bin/sh/var.c
==============================================================================
--- stable/8/bin/sh/var.c	Tue Apr 20 22:24:35 2010	(r206943)
+++ stable/8/bin/sh/var.c	Tue Apr 20 22:32:34 2010	(r206944)
@@ -604,7 +604,6 @@ exportcmd(int argc, char **argv)
 
 	if (values && argc != 0)
 		error("-p requires no arguments");
-	listsetvar(cmdenviron);
 	if (argc != 0) {
 		while ((name = *argv++) != NULL) {
 			if ((p = strchr(name, '=')) != NULL) {


More information about the svn-src-all mailing list