svn commit: r200943 - head/bin/sh
Jilles Tjoelker
jilles at FreeBSD.org
Thu Dec 24 15:14:23 UTC 2009
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) {
More information about the svn-src-head
mailing list