summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-12-28 23:40:46 +0000
committerjilles <jilles@FreeBSD.org>2011-12-28 23:40:46 +0000
commit0121cc11e8024769d9c650455af23585d1f6099e (patch)
treec6f276f02519d6702acd84f1bd9001bc2ebecf83 /bin/sh
parentf9224784391f6d5bc219e7779fa000ba9a68963b (diff)
downloadFreeBSD-src-0121cc11e8024769d9c650455af23585d1f6099e.zip
FreeBSD-src-0121cc11e8024769d9c650455af23585d1f6099e.tar.gz
sh: Use dirent.d_type in pathname generation.
This improves performance for globs where a slash or another component follows a component with metacharacters by eliminating unnecessary attempts to open directories that are not.
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/expand.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index df05a9a..75dcf5c 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -1292,6 +1292,10 @@ expmeta(char *enddir, char *name)
if (atend)
addfname(expdir);
else {
+ if (dp->d_type != DT_UNKNOWN &&
+ dp->d_type != DT_DIR &&
+ dp->d_type != DT_LNK)
+ continue;
if (enddir + namlen + 2 > expdir_end)
continue;
enddir[namlen] = '/';
OpenPOWER on IntegriCloud