aboutsummaryrefslogtreecommitdiffhomepage
path: root/wildcard.cpp
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-09-20 00:26:10 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-09-20 00:31:33 -0700
commit8a3cf144f25dd0cb1e20928b2c2f2c53b34c40c3 (patch)
tree362fd43b490ecea73a023f249106bf9e35455ff7 /wildcard.cpp
parenta381ac2691b7c1d52ec7436a7c97ba91b3d496aa (diff)
Don't include child directories of $PATH in completions
Directories are completed like commands, because of implicit cd. However, directories found inside $PATH entries should not be completed, as implicit cd doesn't work there. Similarly, directories should not be completed after the `command` builtin. Fixes #1695.
Diffstat (limited to 'wildcard.cpp')
-rw-r--r--wildcard.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/wildcard.cpp b/wildcard.cpp
index fde6ddc6..7814a53f 100644
--- a/wildcard.cpp
+++ b/wildcard.cpp
@@ -732,6 +732,16 @@ static bool test_flags(const wchar_t *filename, expand_flags_t flags)
{
if (waccess(filename, X_OK) != 0)
return false;
+ struct stat buf;
+ if (wstat(filename, &buf) == -1)
+ {
+ return false;
+ }
+
+ if (!S_ISREG(buf.st_mode))
+ {
+ return false;
+ }
}
return true;