mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-04-01 17:35:13 +08:00
Fix for broken variable export
darcs-hash:20050923231538-ac50b-60e0a827ce74a168dce0cca34ce96cf89c12ada9.gz
This commit is contained in:
parent
61af4e2197
commit
9714521bf4
34
env.c
34
env.c
@ -129,14 +129,6 @@ static buffer_t export_buffer;
|
|||||||
*/
|
*/
|
||||||
static int has_changed = 1;
|
static int has_changed = 1;
|
||||||
|
|
||||||
/**
|
|
||||||
Number of variables marked for export. The actual number of
|
|
||||||
variables actually exported may be lower because of variable
|
|
||||||
scoping rules.
|
|
||||||
*/
|
|
||||||
static int export_count=0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Free hash key and hash value
|
Free hash key and hash value
|
||||||
*/
|
*/
|
||||||
@ -257,13 +249,13 @@ void env_init()
|
|||||||
*val = L'\0';
|
*val = L'\0';
|
||||||
val++;
|
val++;
|
||||||
pos=val;
|
pos=val;
|
||||||
|
//fwprintf( stderr, L"Set $%ls to %ls\n", key, val );
|
||||||
while( *pos )
|
while( *pos )
|
||||||
{
|
{
|
||||||
if( *pos == L':' )
|
if( *pos == L':' )
|
||||||
*pos = ARRAY_SEP;
|
*pos = ARRAY_SEP;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
// fwprintf( stderr, L"Set $%ls to %ls\n", key, val );
|
|
||||||
|
|
||||||
env_set( key, val, ENV_EXPORT | ENV_GLOBAL );
|
env_set( key, val, ENV_EXPORT | ENV_GLOBAL );
|
||||||
}
|
}
|
||||||
@ -402,6 +394,9 @@ void env_set( const wchar_t *key,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if( !proc_had_barrier)
|
||||||
|
env_universal_barrier();
|
||||||
|
|
||||||
if( env_universal_get( key ) )
|
if( env_universal_get( key ) )
|
||||||
{
|
{
|
||||||
int export = 0;
|
int export = 0;
|
||||||
@ -437,7 +432,6 @@ void env_set( const wchar_t *key,
|
|||||||
if( var_mode & ENV_EXPORT)
|
if( var_mode & ENV_EXPORT)
|
||||||
{
|
{
|
||||||
entry->export = 1;
|
entry->export = 1;
|
||||||
export_count++;
|
|
||||||
has_changed_new = 1;
|
has_changed_new = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -455,11 +449,12 @@ void env_set( const wchar_t *key,
|
|||||||
if( free_val )
|
if( free_val )
|
||||||
free((void *)val);
|
free((void *)val);
|
||||||
|
|
||||||
// if( has_changed_new && !has_changed_old )
|
|
||||||
// fwprintf( stderr, L"Reexport after setting %ls to %ls\n", key, val );
|
|
||||||
|
|
||||||
has_changed = has_changed_old | has_changed_new;
|
has_changed = has_changed_old || has_changed_new;
|
||||||
|
|
||||||
|
/* if( has_changed_new && !has_changed_old )
|
||||||
|
fwprintf( stderr, L"Reexport after setting %ls to %ls, %d %d %d\n", key, val, has_changed_old, has_changed_new, has_changed );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -482,7 +477,6 @@ static int try_remove( env_node_t *n,
|
|||||||
var_entry_t * v = (var_entry_t *)old_val;
|
var_entry_t * v = (var_entry_t *)old_val;
|
||||||
if( v->export )
|
if( v->export )
|
||||||
{
|
{
|
||||||
export_count --;
|
|
||||||
has_changed = 1;
|
has_changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,6 +556,8 @@ wchar_t *env_get( const wchar_t *key )
|
|||||||
else
|
else
|
||||||
env = env->next;
|
env = env->next;
|
||||||
}
|
}
|
||||||
|
if( !proc_had_barrier)
|
||||||
|
env_universal_barrier();
|
||||||
return env_universal_get( key );
|
return env_universal_get( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,7 +585,7 @@ void env_push( int new_scope )
|
|||||||
node->new_scope=new_scope;
|
node->new_scope=new_scope;
|
||||||
if( new_scope )
|
if( new_scope )
|
||||||
{
|
{
|
||||||
has_changed = local_scope_exports(top);
|
has_changed |= local_scope_exports(top);
|
||||||
}
|
}
|
||||||
top = node;
|
top = node;
|
||||||
|
|
||||||
@ -611,7 +607,7 @@ void env_pop()
|
|||||||
|
|
||||||
if( killme->new_scope )
|
if( killme->new_scope )
|
||||||
{
|
{
|
||||||
has_changed = killme->export || local_scope_exports( killme->next );
|
has_changed |= killme->export || local_scope_exports( killme->next );
|
||||||
}
|
}
|
||||||
|
|
||||||
top = top->next;
|
top = top->next;
|
||||||
@ -770,9 +766,11 @@ static void export_func2( const void *k, const void *v, void *aux )
|
|||||||
|
|
||||||
char **env_export_arr( int recalc)
|
char **env_export_arr( int recalc)
|
||||||
{
|
{
|
||||||
if( recalc )
|
if( recalc && !proc_had_barrier)
|
||||||
env_universal_barrier();
|
env_universal_barrier();
|
||||||
|
|
||||||
|
// debug( 1, L"env_export_arr() %d %d", has_changed, env_universal_update );
|
||||||
|
|
||||||
if( has_changed || env_universal_update )
|
if( has_changed || env_universal_update )
|
||||||
{
|
{
|
||||||
array_list_t uni;
|
array_list_t uni;
|
||||||
@ -782,7 +780,7 @@ char **env_export_arr( int recalc)
|
|||||||
int pos=0;
|
int pos=0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
debug( 3, L"env_export_arr()" );
|
// debug( 1, L"env_export_arr() recalc" );
|
||||||
|
|
||||||
hash_init( &vals, &hash_wcs_func, &hash_wcs_cmp );
|
hash_init( &vals, &hash_wcs_func, &hash_wcs_cmp );
|
||||||
|
|
||||||
|
@ -260,8 +260,6 @@ wchar_t *env_universal_get( const wchar_t *name )
|
|||||||
if( !name )
|
if( !name )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
env_universal_barrier();
|
|
||||||
|
|
||||||
return env_universal_common_get( name );
|
return env_universal_common_get( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
parser.c
2
parser.c
@ -1625,6 +1625,8 @@ static void eval_job( tokenizer *tok )
|
|||||||
j->constructed=0;
|
j->constructed=0;
|
||||||
j->skip_notification = is_subshell;
|
j->skip_notification = is_subshell;
|
||||||
|
|
||||||
|
proc_had_barrier=0;
|
||||||
|
|
||||||
if( is_interactive )
|
if( is_interactive )
|
||||||
{
|
{
|
||||||
if( tcgetattr (0, &j->tmodes) )
|
if( tcgetattr (0, &j->tmodes) )
|
||||||
|
2
proc.c
2
proc.c
@ -69,7 +69,7 @@ int is_interactive_session=0;
|
|||||||
int is_subshell=0;
|
int is_subshell=0;
|
||||||
int is_block=0;
|
int is_block=0;
|
||||||
int is_login=0;
|
int is_login=0;
|
||||||
|
int proc_had_barrier;
|
||||||
pid_t proc_last_bg_pid = 0;
|
pid_t proc_last_bg_pid = 0;
|
||||||
|
|
||||||
io_data_t *io_add( io_data_t *list, io_data_t *element )
|
io_data_t *io_add( io_data_t *list, io_data_t *element )
|
||||||
|
11
proc.h
11
proc.h
@ -150,6 +150,17 @@ extern int is_login;
|
|||||||
/** Linked list of all jobs */
|
/** Linked list of all jobs */
|
||||||
extern job_t *first_job;
|
extern job_t *first_job;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whether a universal variable barrier roundtrip has already been
|
||||||
|
made for this command. Such a roundtrip only needs to be done once
|
||||||
|
on a given command, unless a unversal variable value is
|
||||||
|
changed. Once this has been done, this variable is set to 1, so
|
||||||
|
that no more roundtrips need to be done.
|
||||||
|
|
||||||
|
Both setting it to one when it should be zero and the opposite may
|
||||||
|
cause concurrency bugs.
|
||||||
|
*/
|
||||||
|
extern int proc_had_barrier;
|
||||||
|
|
||||||
extern pid_t proc_last_bg_pid;
|
extern pid_t proc_last_bg_pid;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user