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.
Obtained-from: FreeBSD 228942
(cherry picked from commit
c601174268e0ea6cad93a733cecb3a07b2c503a6)
* SUCH DAMAGE.
*
* @(#)expand.c 8.5 (Berkeley) 5/15/95
- * $FreeBSD: src/bin/sh/expand.c,v 1.92 2011/12/28 23:30:17 jilles Exp $
+ * $FreeBSD: src/bin/sh/expand.c,v 1.93 2011/12/28 23:40:46 jilles Exp $
*/
#include <sys/types.h>
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] = '/';