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:
axel 2006-11-23 20:40:23 +10:00
parent 338d32a7c6
commit cab80b452b
2 changed files with 23 additions and 40 deletions

View File

@ -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,
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 );
/*
Don't care if we fail - completions are just hints
*/
}
else
{
free(nxt);
}
}
}
}
al_destroy( &tmp );
}
}

View File

@ -391,24 +391,30 @@ 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;
if( flags & DIRECTORIES_ONLY )
{
struct stat buf;
if( wstat( filename, &buf ) == -1 )
{
return 0;
}
if( S_ISDIR( buf.st_mode ) )
return 1;
if( !S_ISDIR( buf.st_mode ) )
{
return 0;
}
}
if( flags & EXECUTABLES_ONLY )
return ( waccess( filename, X_OK ) == 0);
{
if ( waccess( filename, X_OK ) != 0)
return 0;
}
return 1;
}
int wildcard_expand( const wchar_t *wc,
const wchar_t *base_dir,