svn commit: r212467 - in head: bin/sh
tools/regression/bin/sh/execution
Jilles Tjoelker
jilles at FreeBSD.org
Sat Sep 11 14:15:50 UTC 2010
Author: jilles
Date: Sat Sep 11 14:15:50 2010
New Revision: 212467
URL: http://svn.freebsd.org/changeset/base/212467
Log:
sh: Apply variable assignments left-to-right in bltinlookup().
Example:
HOME=foo HOME=bar cd
Added:
head/tools/regression/bin/sh/execution/var-assign1.0 (contents, props changed)
Modified:
head/bin/sh/var.c
Modified: head/bin/sh/var.c
==============================================================================
--- head/bin/sh/var.c Sat Sep 11 13:06:06 2010 (r212466)
+++ head/bin/sh/var.c Sat Sep 11 14:15:50 2010 (r212467)
@@ -431,11 +431,15 @@ bltinlookup(const char *name, int doall)
{
struct strlist *sp;
struct var *v;
+ char *result;
+ result = NULL;
for (sp = cmdenviron ; sp ; sp = sp->next) {
if (varequal(sp->text, name))
- return strchr(sp->text, '=') + 1;
+ result = strchr(sp->text, '=') + 1;
}
+ if (result != NULL)
+ return result;
for (v = *hashvar(name) ; v ; v = v->next) {
if (varequal(v->text, name)) {
if ((v->flags & VUNSET)
Added: head/tools/regression/bin/sh/execution/var-assign1.0
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/tools/regression/bin/sh/execution/var-assign1.0 Sat Sep 11 14:15:50 2010 (r212467)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+[ "$(HOME=/etc HOME=/ cd && pwd)" = / ]
More information about the svn-src-all
mailing list