mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-03 20:15:42 +08:00
Fix bug in completion code reported by Martin Bähr, as well as other bug evident in his bug report.
darcs-hash:20060826013722-ac50b-08de084a40af8ba5d708a7cd162087b7afbb7648.gz
This commit is contained in:
parent
0a603a56c6
commit
69537430ea
@ -455,6 +455,8 @@ static int builtin_set( wchar_t **argv )
|
|||||||
int slice=0;
|
int slice=0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
wchar_t *bad_char;
|
||||||
|
|
||||||
|
|
||||||
/* Parse options to obtain the requested operation and the modifiers */
|
/* Parse options to obtain the requested operation and the modifiers */
|
||||||
woptind = 0;
|
woptind = 0;
|
||||||
@ -629,7 +631,7 @@ static int builtin_set( wchar_t **argv )
|
|||||||
print_variables(0, 0, scope);
|
print_variables(0, 0, scope);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !(dest = wcsdup(argv[woptind])))
|
if( !(dest = wcsdup(argv[woptind])))
|
||||||
{
|
{
|
||||||
DIE_MEM();
|
DIE_MEM();
|
||||||
@ -649,6 +651,15 @@ static int builtin_set( wchar_t **argv )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( (bad_char = wcsvarname( dest ) ) )
|
||||||
|
{
|
||||||
|
sb_printf( sb_err, BUILTIN_ERR_VARCHAR, argv[0], *bad_char );
|
||||||
|
builtin_print_help( argv[0], sb_err );
|
||||||
|
free( dest );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if( slice && erase && (scope != ENV_USER) )
|
if( slice && erase && (scope != ENV_USER) )
|
||||||
{
|
{
|
||||||
free( dest );
|
free( dest );
|
||||||
@ -678,7 +689,7 @@ static int builtin_set( wchar_t **argv )
|
|||||||
al_init(&result);
|
al_init(&result);
|
||||||
|
|
||||||
tokenize_variable_array( env_get(dest), &result );
|
tokenize_variable_array( env_get(dest), &result );
|
||||||
|
|
||||||
for( ; woptind<argc; woptind++ )
|
for( ; woptind<argc; woptind++ )
|
||||||
{
|
{
|
||||||
if( !parse_index( &indexes, argv[woptind], dest, al_get_count( &result ) ) )
|
if( !parse_index( &indexes, argv[woptind], dest, al_get_count( &result ) ) )
|
||||||
|
27
complete.c
27
complete.c
@ -1820,20 +1820,27 @@ static int complete_variable( const wchar_t *var,
|
|||||||
|
|
||||||
if( wcsncmp( var, name, varlen) == 0 )
|
if( wcsncmp( var, name, varlen) == 0 )
|
||||||
{
|
{
|
||||||
wchar_t *value = expand_escape_variable( env_get( name ));
|
wchar_t *value_unescaped, *value;
|
||||||
|
|
||||||
wchar_t *blarg;
|
wchar_t *blarg;
|
||||||
/*
|
|
||||||
Variable description is 'Variable: VALUE
|
|
||||||
*/
|
|
||||||
blarg = wcsdupcat2( &name[varlen], COMPLETE_SEP_STR, COMPLETE_VAR_DESC_VAL, value, 0 );
|
|
||||||
|
|
||||||
if( blarg )
|
value_unescaped = env_get( name );
|
||||||
|
if( value_unescaped )
|
||||||
{
|
{
|
||||||
res =1;
|
value = expand_escape_variable( value_unescaped );
|
||||||
al_push( comp, blarg );
|
/*
|
||||||
|
Variable description is 'Variable: VALUE
|
||||||
|
*/
|
||||||
|
blarg = wcsdupcat2( &name[varlen], COMPLETE_SEP_STR, COMPLETE_VAR_DESC_VAL, value, 0 );
|
||||||
|
|
||||||
|
if( blarg )
|
||||||
|
{
|
||||||
|
res =1;
|
||||||
|
al_push( comp, blarg );
|
||||||
|
}
|
||||||
|
free( value );
|
||||||
}
|
}
|
||||||
free( value );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user