mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Make command specific completions handle quoted and otherwise escaped tokens better by making sure that the output from the commandline builtin is properly unescaped
darcs-hash:20070118162700-ac50b-cd93d9a6aff5bb7629a790d60b241000eb1d0ac0.gz
This commit is contained in:
parent
9e7094adfc
commit
421aff7d67
4 changed files with 33 additions and 19 deletions
|
@ -146,7 +146,6 @@ static void write_part( const wchar_t *begin,
|
|||
|
||||
if( tokenize )
|
||||
{
|
||||
|
||||
buff = wcsndup( begin, end-begin );
|
||||
// fwprintf( stderr, L"Subshell: %ls, end char %lc\n", buff, *end );
|
||||
sb_init( &out );
|
||||
|
@ -159,20 +158,21 @@ static void write_part( const wchar_t *begin,
|
|||
(tok_get_pos( &tok)+wcslen(tok_last( &tok)) >= pos) )
|
||||
break;
|
||||
|
||||
// fwprintf( stderr, L"Next token %ls\n", tok_last( &tok ) );
|
||||
|
||||
switch( tok_last_type( &tok ) )
|
||||
{
|
||||
case TOK_STRING:
|
||||
sb_append2( &out, tok_last( &tok), L"\n", (void *)0 );
|
||||
{
|
||||
wchar_t *tmp = unescape( tok_last( &tok ), UNESCAPE_INCOMPLETE );
|
||||
sb_append2( &out, tmp, L"\n", (void *)0 );
|
||||
free( tmp );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( out.buff )
|
||||
sb_append( sb_out,
|
||||
(wchar_t *)out.buff );
|
||||
|
||||
sb_append( sb_out,
|
||||
(wchar_t *)out.buff );
|
||||
|
||||
free( buff );
|
||||
tok_destroy( &tok );
|
||||
|
@ -180,12 +180,24 @@ static void write_part( const wchar_t *begin,
|
|||
}
|
||||
else
|
||||
{
|
||||
wchar_t *buff, *esc;
|
||||
|
||||
if( cut_at_cursor )
|
||||
{
|
||||
end = begin+pos;
|
||||
}
|
||||
sb_append_substring( sb_out, begin, end-begin );
|
||||
sb_append( sb_out, L"\n" );
|
||||
|
||||
buff = wcsndup( begin, end-begin );
|
||||
esc = unescape( buff, UNESCAPE_INCOMPLETE );
|
||||
|
||||
// debug( 0, L"woot2 %ls -> %ls", buff, esc );
|
||||
|
||||
sb_append( sb_out, esc );
|
||||
sb_append( sb_out, L"\n" );
|
||||
|
||||
free( esc );
|
||||
free( buff );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
common.c
2
common.c
|
@ -1303,7 +1303,7 @@ wchar_t *unescape( const wchar_t * orig, int flags )
|
|||
free( in );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
in[out_pos]=L'\0';
|
||||
return in;
|
||||
}
|
||||
|
|
10
expand.c
10
expand.c
|
@ -1584,8 +1584,14 @@ int expand_string( void *context,
|
|||
{
|
||||
wchar_t *next;
|
||||
|
||||
next = expand_unescape( (wchar_t *)al_get( in, i ),
|
||||
1);
|
||||
/*
|
||||
We accept incomplete strings here, since complete uses
|
||||
expand_string to expand incomplete strings from the
|
||||
commandline.
|
||||
*/
|
||||
int unescape_flags = UNESCAPE_SPECIAL | UNESCAPE_INCOMPLETE;
|
||||
|
||||
next = expand_unescape( (wchar_t *)al_get( in, i ), unescape_flags );
|
||||
|
||||
free( (void *)al_get( in, i ) );
|
||||
|
||||
|
|
|
@ -202,11 +202,7 @@ int tok_has_next( tokenizer *tok )
|
|||
|
||||
static int is_string_char( wchar_t c )
|
||||
{
|
||||
if( !c || wcschr( SEP, c ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return !( !c || wcschr( SEP, c ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue