Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Dec 2009 15:14:22 +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: r200943 - head/bin/sh
Message-ID:  <200912241514.nBOFEMct033633@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Thu Dec 24 15:14:22 2009
New Revision: 200943
URL: http://svn.freebsd.org/changeset/base/200943

Log:
  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 will 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:
  head/bin/sh/main.c
  head/bin/sh/var.c

Modified: head/bin/sh/main.c
==============================================================================
--- head/bin/sh/main.c	Thu Dec 24 14:32:21 2009	(r200942)
+++ head/bin/sh/main.c	Thu Dec 24 15:14:22 2009	(r200943)
@@ -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: head/bin/sh/var.c
==============================================================================
--- head/bin/sh/var.c	Thu Dec 24 14:32:21 2009	(r200942)
+++ head/bin/sh/var.c	Thu Dec 24 15:14:22 2009	(r200943)
@@ -607,7 +607,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?200912241514.nBOFEMct033633>