Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Apr 2010 22:32:34 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r206944 - stable/8/bin/sh
Message-ID:  <201004202232.o3KMWYso064377@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004202232.o3KMWYso064377>