mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Fix problem bug breaking completion in commands with multiple subshells
darcs-hash:20051025110352-ac50b-fff319ddcbafb722b9bc3c61aa1b250b290716a5.gz
This commit is contained in:
parent
d332293245
commit
ddcb84aa07
9 changed files with 39 additions and 26 deletions
2
common.c
2
common.c
|
@ -911,7 +911,7 @@ void debug( int level, wchar_t *msg, ... )
|
|||
|
||||
}
|
||||
putwc( L'\n', stderr );
|
||||
|
||||
sb_destroy( &sb );
|
||||
}
|
||||
|
||||
wchar_t *escape( const wchar_t *in,
|
||||
|
|
2
common.h
2
common.h
|
@ -270,7 +270,7 @@ wchar_t *escape( const wchar_t *in,
|
|||
counterparts. Also optionally change the wildcards, the tilde
|
||||
character and a few more into constants which are defined in a
|
||||
private use area of Unicode. This assumes wchar_t is a unicode
|
||||
character. character set.
|
||||
character set.
|
||||
|
||||
The result must be free()d. The original string is not modified. If
|
||||
an invalid sequence is specified, 0 is returned.
|
||||
|
|
|
@ -1765,10 +1765,10 @@ static void complete_param_expand( wchar_t *str,
|
|||
}
|
||||
else
|
||||
comp_str = str;
|
||||
|
||||
// fwprintf( stderr, L"expand_string( \"%ls\", [list], ACCEPT_INCOMPLETE | %ls )\n", comp_str, do_file?L"0":L"EXPAND_SKIP_WILDCARDS" );
|
||||
|
||||
expand_string( wcsdup(comp_str), comp_out, ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) );
|
||||
// fwprintf( stderr, L"expand_string( \"%ls\", [list], EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | %ls )\n", comp_str, do_file?L"0":L"EXPAND_SKIP_WILDCARDS" );
|
||||
|
||||
expand_string( wcsdup(comp_str), comp_out, EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
10
env.c
10
env.c
|
@ -388,8 +388,12 @@ void env_init()
|
|||
|
||||
|
||||
pw = getpwuid( getuid() );
|
||||
uname = str2wcs( pw->pw_name );
|
||||
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT );
|
||||
if( pw )
|
||||
{
|
||||
uname = str2wcs( pw->pw_name );
|
||||
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT );
|
||||
free( uname );
|
||||
}
|
||||
|
||||
env_universal_init( env_get( L"FISHD_SOKET_DIR"),
|
||||
env_get( L"USER" ),
|
||||
|
@ -410,6 +414,8 @@ void env_destroy()
|
|||
env_pop();
|
||||
|
||||
hash_destroy( &env_read_only );
|
||||
|
||||
hash_destroy( &env_electric );
|
||||
|
||||
hash_foreach( global, &clear_hash_entry );
|
||||
hash_destroy( global );
|
||||
|
|
2
expand.c
2
expand.c
|
@ -1328,6 +1328,7 @@ int expand_string( wchar_t *str,
|
|||
if( (pos == str) || ( *(pos-1) != L'\\' ) )
|
||||
{
|
||||
error( SUBSHELL_ERROR, L"Subshells not allowed", -1 );
|
||||
free( str );
|
||||
al_destroy( &list1 );
|
||||
al_destroy( &list2 );
|
||||
return 0;
|
||||
|
@ -1505,7 +1506,6 @@ wchar_t *expand_one( wchar_t *string, int flags )
|
|||
res = expand_string( string, &l, flags );
|
||||
if( !res )
|
||||
{
|
||||
free( string );
|
||||
one = 0;
|
||||
}
|
||||
else
|
||||
|
|
2
expand.h
2
expand.h
|
@ -162,7 +162,7 @@ wchar_t *expand_escape_variable( const wchar_t *in );
|
|||
wchar_t *expand_tilde(wchar_t *in);
|
||||
|
||||
/**
|
||||
Locate the last subshell in the specified string.
|
||||
Locate the first subshell in the specified string.
|
||||
|
||||
\param in the string to search for subshells
|
||||
\param begin the starting paranthesis of the subshell
|
||||
|
|
|
@ -357,7 +357,7 @@ void highlight_shell( wchar_t * buff,
|
|||
/*
|
||||
Locate and syntax highlight subshells recursively
|
||||
*/
|
||||
|
||||
|
||||
wchar_t *buffcpy = wcsdup( buff );
|
||||
wchar_t *subpos=buffcpy;
|
||||
int done=0;
|
||||
|
@ -386,8 +386,9 @@ void highlight_shell( wchar_t * buff,
|
|||
break;
|
||||
|
||||
subpos = end+1;
|
||||
|
||||
}
|
||||
free( buffcpy );
|
||||
free( buffcpy);
|
||||
|
||||
|
||||
last_val=0;
|
||||
|
|
|
@ -942,7 +942,7 @@ function psub -d "Read from stdin into a file and output the filename. Remove th
|
|||
end
|
||||
|
||||
if not status --is-command-substitution
|
||||
echo psub: Not inside of command substitution
|
||||
echo psub: Not inside of command substitution >&2
|
||||
return
|
||||
end
|
||||
|
||||
|
|
34
reader.c
34
reader.c
|
@ -1548,9 +1548,9 @@ void reader_sanity_check()
|
|||
|
||||
void reader_current_subshell_extent( wchar_t **a, wchar_t **b )
|
||||
{
|
||||
wchar_t *buffcpy = wcsdup( data->buff );
|
||||
wchar_t *begin, *end;
|
||||
|
||||
wchar_t *pos;
|
||||
|
||||
if( a )
|
||||
*a=0;
|
||||
if( b )
|
||||
|
@ -1559,35 +1559,41 @@ void reader_current_subshell_extent( wchar_t **a, wchar_t **b )
|
|||
if( !data )
|
||||
return;
|
||||
|
||||
pos = data->buff;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
int bc, ec;
|
||||
|
||||
if( expand_locate_subshell( buffcpy,
|
||||
|
||||
if( expand_locate_subshell( pos,
|
||||
&begin,
|
||||
&end,
|
||||
1 ) <= 0)
|
||||
{
|
||||
begin=buffcpy;
|
||||
end = buffcpy + wcslen(data->buff);
|
||||
begin=data->buff;
|
||||
end = data->buff + wcslen(data->buff);
|
||||
break;
|
||||
}
|
||||
bc = begin-buffcpy;
|
||||
ec = end-buffcpy;
|
||||
|
||||
if( !end )
|
||||
{
|
||||
end = data->buff + wcslen(data->buff);
|
||||
}
|
||||
|
||||
bc = begin-data->buff;
|
||||
ec = end-data->buff;
|
||||
|
||||
if(( bc < data->buff_pos ) && (ec >= data->buff_pos) )
|
||||
{
|
||||
begin++;
|
||||
|
||||
//fwprintf( stderr, L"Subshell!\n" );
|
||||
break;
|
||||
}
|
||||
*begin=0;
|
||||
pos = end+1;
|
||||
}
|
||||
if( a )
|
||||
*a = data->buff + (begin-buffcpy);
|
||||
*a = begin;
|
||||
if( b )
|
||||
*b = data->buff + (end-buffcpy);
|
||||
free( buffcpy );
|
||||
*b = end;
|
||||
}
|
||||
|
||||
static void reader_current_job_or_process_extent( wchar_t **a,
|
||||
|
|
Loading…
Reference in a new issue