summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dir.c2
-rw-r--r--test/ruby/test_dir.rb14
2 files changed, 15 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index a3ea5eea50..a35aace6f1 100644
--- a/dir.c
+++ b/dir.c
@@ -2305,7 +2305,7 @@ glob_helper(
#endif
break;
case BRACE:
- if (!recursive) {
+ if (!recursive || strchr(p->str, '/')) {
brace = 1;
}
break;
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index 514c6e5921..ebbed75445 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -259,6 +259,20 @@ class TestDir < Test::Unit::TestCase
end
end
+ def test_glob_recursive_with_brace
+ Dir.chdir(@root) do
+ bug19042 = '[ruby-core:110220] [Bug #19042]'
+ %w"c/dir_a c/dir_b c/dir_b/dir".each do |d|
+ Dir.mkdir(d)
+ end
+ expected = %w"c/dir_a/file c/dir_b/dir/file"
+ expected.each do |f|
+ File.write(f, "")
+ end
+ assert_equal(expected, Dir.glob("**/{dir_a,dir_b/dir}/file"), bug19042)
+ end
+ end
+
def test_glob_order
Dir.chdir(@root) do
assert_equal(["#{@root}/a", "#{@root}/b"], Dir.glob("#{@root}/[ba]"))