aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dir.c4
-rw-r--r--test/ruby/test_dir.rb14
2 files changed, 18 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 2196344fc3..7e5b80793f 100644
--- a/dir.c
+++ b/dir.c
@@ -2052,6 +2052,10 @@ join_path_from_pattern(struct glob_pattern **beg)
case RECURSIVE:
str = "**";
break;
+ case MATCH_DIR:
+ /* append last slash */
+ str = "";
+ break;
default:
str = p->str;
if (!str) continue;
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index e248c818b6..02b9c32202 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -191,6 +191,20 @@ class TestDir < Test::Unit::TestCase
end
end
+ def test_glob_recursive_directory
+ Dir.chdir(@root) do
+ ['d', 'e'].each do |path|
+ FileUtils.mkdir_p("c/#{path}/a/b/c")
+ FileUtils.touch("c/#{path}/a/a.file")
+ FileUtils.touch("c/#{path}/a/b/b.file")
+ FileUtils.touch("c/#{path}/a/b/c/c.file")
+ end
+ bug15540 = '[ruby-core:91110] [Bug #15540]'
+ assert_equal(["c/d/a/", "c/d/a/b/", "c/d/a/b/c/", "c/e/a/", "c/e/a/b/", "c/e/a/b/c/"],
+ Dir.glob('c/{d,e}/a/**/'), bug15540)
+ end
+ end
+
if Process.const_defined?(:RLIMIT_NOFILE)
def test_glob_too_may_open_files
assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}", chdir: @root)