sh: Apply variable assignments left-to-right in bltinlookup().
Example: HOME=foo HOME=bar cd
This commit is contained in:
parent
9a24dc0760
commit
011d162dd3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=212467
@ -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)
|
||||
|
3
tools/regression/bin/sh/execution/var-assign1.0
Normal file
3
tools/regression/bin/sh/execution/var-assign1.0
Normal file
@ -0,0 +1,3 @@
|
||||
# $FreeBSD$
|
||||
|
||||
[ "$(HOME=/etc HOME=/ cd && pwd)" = / ]
|
Loading…
Reference in New Issue
Block a user