diff --git a/Glob.cxx b/Glob.cxx
index c52aafc4f739658b311dbe1c0c6c206b7e1a8f8f..e4f2ad23b221817276911d1208b3d0dd89bc6b99 100644
--- a/Glob.cxx
+++ b/Glob.cxx
@@ -286,7 +286,9 @@ void Glob::ProcessDirectory(std::string::size_type start,
   // std::cout << "ProcessDirectory: " << dir << std::endl;
   bool last = (start == this->Internals->Expressions.size() - 1);
   if (last && this->Recurse) {
-    this->RecurseDirectory(start, dir, messages);
+    if (kwsys::SystemTools::FileIsDirectory(dir)) {
+      this->RecurseDirectory(start, dir, messages);
+    }
     return;
   }