diff options
author | jilles <jilles@FreeBSD.org> | 2009-12-24 15:14:22 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2009-12-24 15:14:22 +0000 |
commit | 979a1ef888d4a268658576bcd3793a3a47bb707d (patch) | |
tree | ac09eb24e922c647beec91bfabcc7667760f0fae | |
parent | ab355c0d662d8fd56d0d6d17844eb0e1620d0f30 (diff) | |
download | FreeBSD-src-979a1ef888d4a268658576bcd3793a3a47bb707d.zip FreeBSD-src-979a1ef888d4a268658576bcd3793a3a47bb707d.tar.gz |
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'
-rw-r--r-- | bin/sh/main.c | 4 | ||||
-rw-r--r-- | bin/sh/var.c | 1 |
2 files changed, 0 insertions, 5 deletions
diff --git a/bin/sh/main.c b/bin/sh/main.c index f26e611..b27d0cf 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -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; diff --git a/bin/sh/var.c b/bin/sh/var.c index 6caf956..8fa3b5c 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -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) { |