mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix nested functions ignoring prefixed variable assignments (#37)
This commit fixes the bug described in att/ast#32. The fix and following explanation is from att/ast#467: While copying variables from function's local scope to a new scope, variable attributes were not copied. Such variables were not marked to be exported in the new function. For e.g. function f2 { env | grep -i "^foo"; } function f1 { env | grep -i "^foo"; f2; } foo=bar f1 prints 'foo=bar' only once, but it should print be twice. src/cmd/ksh93/sh/xec.c: - When variables from the local scope of a function are copied into the scope of a nested function, the attributes of the variables need to be copied as well. src/cmd/ksh93/tests/functions.sh: - Add regression tests from ksh2020 to check environment variables passed to functions.
This commit is contained in:
parent
e0b326ae15
commit
c1994b87f1
3 changed files with 15 additions and 0 deletions
|
@ -3249,7 +3249,10 @@ static void local_exports(register Namval_t *np, void *data)
|
|||
if(nv_isarray(np))
|
||||
nv_putsub(np,NIL(char*),0);
|
||||
if((cp = nv_getval(np)) && (mp = nv_search(nv_name(np), shp->var_tree, NV_ADD|HASH_NOSCOPE)) && nv_isnull(mp))
|
||||
{
|
||||
nv_putval(mp, cp, 0);
|
||||
mp->nvflag = np->nvflag;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue