mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 10:43:32 +08:00
Fix bug where tab completions for implicit 'cd' would ignore symbolic links to directories
darcs-hash:20061123104023-ac50b-7245f70e0f6fbbc97358e32c6dc7ca5258f24a53.gz
This commit is contained in:
parent
338d32a7c6
commit
cab80b452b
33
complete.c
33
complete.c
|
@ -1389,8 +1389,6 @@ static void complete_cmd( const wchar_t *cmd,
|
|||
nxt_path != 0;
|
||||
nxt_path = wcstok( 0, ARRAY_SEP_STR, &state) )
|
||||
{
|
||||
int i;
|
||||
array_list_t tmp;
|
||||
wchar_t *nxt_completion=
|
||||
wcsdupcat2( nxt_path,
|
||||
(nxt_path[wcslen(nxt_path)-1]==L'/'?L"":L"/"),
|
||||
|
@ -1401,36 +1399,15 @@ static void complete_cmd( const wchar_t *cmd,
|
|||
continue;
|
||||
}
|
||||
|
||||
al_init( &tmp );
|
||||
|
||||
if( expand_string( 0,
|
||||
nxt_completion,
|
||||
&tmp,
|
||||
nxt_completion,
|
||||
comp,
|
||||
ACCEPT_INCOMPLETE | DIRECTORIES_ONLY ) != EXPAND_ERROR )
|
||||
{
|
||||
|
||||
for( i=0; i<al_get_count(&tmp); i++ )
|
||||
{
|
||||
wchar_t *nxt = (wchar_t *)al_get( &tmp, i );
|
||||
|
||||
wchar_t *desc = wcsrchr( nxt, COMPLETE_SEP );
|
||||
if( desc )
|
||||
{
|
||||
int is_valid = desc && (wcscmp(desc+1,
|
||||
COMPLETE_DIRECTORY_DESC)==0);
|
||||
if( is_valid )
|
||||
{
|
||||
al_push( comp, nxt );
|
||||
}
|
||||
else
|
||||
{
|
||||
free(nxt);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
Don't care if we fail - completions are just hints
|
||||
*/
|
||||
}
|
||||
|
||||
al_destroy( &tmp );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
30
wildcard.c
30
wildcard.c
|
@ -391,22 +391,28 @@ static void get_desc( wchar_t *fn, string_buffer_t *sb, int is_cmd )
|
|||
static int test_flags( wchar_t *filename,
|
||||
int flags )
|
||||
{
|
||||
if( !(flags & EXECUTABLES_ONLY) && !(flags & DIRECTORIES_ONLY) )
|
||||
return 1;
|
||||
|
||||
struct stat buf;
|
||||
if( wstat( filename, &buf ) == -1 )
|
||||
if( flags & DIRECTORIES_ONLY )
|
||||
{
|
||||
return 0;
|
||||
struct stat buf;
|
||||
if( wstat( filename, &buf ) == -1 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !S_ISDIR( buf.st_mode ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( S_ISDIR( buf.st_mode ) )
|
||||
return 1;
|
||||
|
||||
|
||||
if( flags & EXECUTABLES_ONLY )
|
||||
return ( waccess( filename, X_OK ) == 0);
|
||||
|
||||
return 0;
|
||||
{
|
||||
if ( waccess( filename, X_OK ) != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user