mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Make sure that command specific completions can handle input strings with wildcards reasonably well
darcs-hash:20060219011432-ac50b-89a73a3d414f2dbd8a213b851fcb1c494e022eae.gz
This commit is contained in:
parent
0840c9248f
commit
43ab84397b
7 changed files with 56 additions and 10 deletions
|
@ -2968,8 +2968,10 @@ static int builtin_case( wchar_t **argv )
|
|||
for( i=1; i<argc; i++ )
|
||||
{
|
||||
free( unescaped );
|
||||
unescaped = unescape( argv[i], 1);
|
||||
|
||||
unescaped = parse_util_unescape_wildcards( argv[i] );
|
||||
|
||||
|
||||
if( wildcard_match( current_block->param1.switch_value, unescaped ) )
|
||||
{
|
||||
current_block->skip = 0;
|
||||
|
|
2
common.c
2
common.c
|
@ -527,8 +527,6 @@ int wcsvarname( wchar_t *str )
|
|||
str++;
|
||||
}
|
||||
return 1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
14
complete.c
14
complete.c
|
@ -1001,17 +1001,21 @@ static void copy_strings_with_prefix( array_list_t *comp_out,
|
|||
array_list_t *possible_comp )
|
||||
{
|
||||
int i;
|
||||
wchar_t *wc;
|
||||
wchar_t *wc, *tmp;
|
||||
|
||||
wc = expand_one( 0,
|
||||
tmp = expand_one( 0,
|
||||
wcsdup(wc_escaped), EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_WILDCARDS);
|
||||
if(!wc)
|
||||
if(!tmp)
|
||||
return;
|
||||
|
||||
if( wc[0] == L'~' )
|
||||
if( tmp[0] == L'~' )
|
||||
{
|
||||
wc=expand_tilde(wc);
|
||||
tmp=expand_tilde(wc);
|
||||
}
|
||||
|
||||
wc = parse_util_unescape_wildcards( tmp );
|
||||
free(tmp);
|
||||
|
||||
|
||||
// int str_len = wcslen( str );
|
||||
for( i=0; i<al_get_count( possible_comp ); i++ )
|
||||
|
|
2
main.c
2
main.c
|
@ -205,7 +205,7 @@ int main( int argc, char **argv )
|
|||
|
||||
my_optind = optind;
|
||||
|
||||
is_login |= strcmp( argv[0], "-fish") == 0;
|
||||
is_login |= (strcmp( argv[0], "-fish") == 0);
|
||||
|
||||
is_interactive_session &= (cmd == 0);
|
||||
is_interactive_session &= (my_optind == argc);
|
||||
|
|
38
parse_util.c
38
parse_util.c
|
@ -25,6 +25,7 @@
|
|||
#include "intern.h"
|
||||
#include "exec.h"
|
||||
#include "env.h"
|
||||
#include "wildcard.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
|
@ -641,4 +642,41 @@ void parse_util_set_argv( wchar_t **argv )
|
|||
}
|
||||
}
|
||||
|
||||
wchar_t *parse_util_unescape_wildcards( const wchar_t *str )
|
||||
{
|
||||
wchar_t *in, *out;
|
||||
wchar_t *unescaped = wcsdup(str);
|
||||
|
||||
if( !unescaped )
|
||||
die_mem();
|
||||
|
||||
for( in=out=unescaped; *in; in++ )
|
||||
{
|
||||
switch( *in )
|
||||
{
|
||||
case L'\\':
|
||||
if( *(in+1) )
|
||||
{
|
||||
in++;
|
||||
*(out++)=*in;
|
||||
}
|
||||
*(out++)=*in;
|
||||
break;
|
||||
|
||||
case L'*':
|
||||
*(out++)=ANY_STRING;
|
||||
break;
|
||||
|
||||
case L'?':
|
||||
*(out++)=ANY_CHAR;
|
||||
break;
|
||||
|
||||
default:
|
||||
*(out++)=*in;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return unescaped;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,4 +87,9 @@ void parse_util_load_reset( const wchar_t *path_var );
|
|||
*/
|
||||
void parse_util_set_argv( wchar_t **argv );
|
||||
|
||||
/**
|
||||
Make duplicate string, unescape wildcard characters but n ot performing any other character transformation
|
||||
*/
|
||||
wchar_t *parse_util_unescape_wildcards( const wchar_t *in );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -72,7 +72,6 @@ int wildcard_has( const wchar_t *str, int internal )
|
|||
\param str String to be matched.
|
||||
\param wc The wildcard.
|
||||
\param is_first Whether files beginning with dots should not be matched against wildcards.
|
||||
\param wc_unescaped Whether the unescaped special character ANY_CHAR abd ANY_STRING should be used instead of '?' and '*' for wildcard matching
|
||||
*/
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue