From cab80b452bb3dbd65d5e8a1eeb869d84a7a94742 Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 23 Nov 2006 20:40:23 +1000 Subject: Fix bug where tab completions for implicit 'cd' would ignore symbolic links to directories darcs-hash:20061123104023-ac50b-7245f70e0f6fbbc97358e32c6dc7ca5258f24a53.gz --- wildcard.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'wildcard.c') diff --git a/wildcard.c b/wildcard.c index 2b0e2ca8..ffce9803 100644 --- a/wildcard.c +++ b/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; } -- cgit v1.2.3