diff --git a/ChangeLog b/ChangeLog index 59f59086f..1b25f08f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ * env.c, builtin_set.c (env_exist, env_get, env_set, builtin_set): Add support for zero element arrays + * env.c (env_set): Default scope for variables is innermost function block + 2005-09-25 Axel Liljencrantz * parser.c: (parse_job, parser_skip_arguemnts, paresr_Test): No semicolon required after else and begin diff --git a/env.c b/env.c index 0c3dbf6c4..5d537b408 100644 --- a/env.c +++ b/env.c @@ -377,7 +377,7 @@ void env_set( const wchar_t *key, } node = env_get_node( key ); - if( &node->env != 0 ) + if( node && &node->env != 0 ) { e = (var_entry_t *) hash_get( &node->env, key ); @@ -425,7 +425,13 @@ void env_set( const wchar_t *key, } else { + /* + New variable with unspecified scope. The default scope is the innermost scope that is shadowing + */ node = top; + while( node->next && !node->new_scope ) + node = node->next; + } } }