diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | dir.c | 6 | ||||
-rw-r--r-- | test/ruby/test_dir.rb | 9 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 18 insertions, 5 deletions
@@ -1,3 +1,9 @@ +Sat Apr 20 23:32:06 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * dir.c (glob_helper): should skip dot directories only for recursion, + but should not if matching to the given pattern. [ruby-core:54387] + [Bug #8283] + Sat Apr 20 02:37:33 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> * ext/curses/curses.c (Init_curses): fix implementation function, @@ -1386,9 +1386,6 @@ glob_helper( enum answer new_isdir = UNKNOWN; if (recursive && dp->d_name[0] == '.') { - /* RECURSIVE never match dot files unless FNM_DOTMATCH is set */ - if (!(flags & FNM_DOTMATCH)) continue; - /* always skip current and parent directories not to recurse infinitely */ if (!dp->d_name[1]) continue; if (dp->d_name[1] == '.' && !dp->d_name[2]) continue; @@ -1399,7 +1396,8 @@ glob_helper( status = -1; break; } - if (recursive) { + if (recursive && ((flags & FNM_DOTMATCH) || dp->d_name[0] != '.')) { + /* RECURSIVE never match dot files unless FNM_DOTMATCH is set */ #ifndef _WIN32 if (do_lstat(buf, &st, flags) == 0) new_isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO; diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 21902298c0..1c8f73e20c 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -177,6 +177,15 @@ class TestDir < Test::Unit::TestCase assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/?/e/f"), bug6977) assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/**/d/e/f"), bug6977) assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/**/d/e/f"), bug6977) + + bug8283 = '[ruby-core:54387] [Bug #8283]' + dirs = ["a/.x", "a/b/.y"] + FileUtils.mkdir_p(dirs) + dirs.map {|dir| open("#{dir}/z", "w") {}} + assert_equal([], Dir.glob("a/**/z").sort, bug8283) + assert_equal(["a/.x/z"], Dir.glob("a/**/.x/z"), bug8283) + assert_equal(["a/.x/z"], Dir.glob("a/.x/**/z"), bug8283) + assert_equal(["a/b/.y/z"], Dir.glob("a/**/.y/z"), bug8283) end end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-04-20" -#define RUBY_PATCHLEVEL 155 +#define RUBY_PATCHLEVEL 156 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 4 |