aboutsummaryrefslogtreecommitdiffhomepage
path: root/wildcard.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-11-23 20:40:23 +1000
committerGravatar axel <axel@liljencrantz.se>2006-11-23 20:40:23 +1000
commitcab80b452bb3dbd65d5e8a1eeb869d84a7a94742 (patch)
tree4234e9b7cb5e97d80980d94e5f772f34e6737ce0 /wildcard.c
parent338d32a7c63bbe6f788dc684bbc17ec2c3712676 (diff)
Fix bug where tab completions for implicit 'cd' would ignore symbolic links to directories
darcs-hash:20061123104023-ac50b-7245f70e0f6fbbc97358e32c6dc7ca5258f24a53.gz
Diffstat (limited to 'wildcard.c')
-rw-r--r--wildcard.c30
1 files changed, 18 insertions, 12 deletions
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;
}