Backport #8283
closedDir.glob doesn't recurse hidden directories
Description
Hello,
I noticed Dir.glob('**') doesn't recurse hidden directories.
I believe regression has been introduced by r36903.
Here is the following directory / file structure:
$ find .
.
./foo
./foo/.bar
./foo/.bar/baz.txt
./foo/bar
And here is the behavior of ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin11.4.2]:
$ ruby -e "puts Dir.glob('**/*')"
foo
foo/bar
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Status changed from Open to Rejected
$ /usr/bin/ruby -v -e 'puts Dir.glob("**/*")'
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]
foo
foo/bar
Updated by gpakosz (Gregory Pakosz) over 11 years ago
well actually behavior changed between ruby 1.9.3-p392 and ruby 2.0.0-p0
I have a script that does:
local_repositories = []
Dir['_all/**/.git/config'].each do |f|
config = IniFile.load(f)
url = config['remote "origin"']['url']
local_repositories << (url.end_with?('.git') ? url : "#{url}.git")
end
and that broke when upgrading to ruby 2.0.0-p0
with ruby 2.0.0-p0, Dir.glob doesn't enter .git directories at all
I had to change the expression to Dir['_all/*/.git/config']
so there is indeed a behavior change between ruby 1.9.3-p392 and ruby 2.0.0-p0, other people confirmed on their boxes on #ruby freenode
can you please reconsider the rejection?
thank you
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Status changed from Rejected to Assigned
- Assignee set to nobu (Nobuyoshi Nakada)
OK, that example makes sense.
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r40345.
Gregory, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
dir.c: not skip dot directories if matching
- 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]
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport200
- Category deleted (
core) - Status changed from Closed to Assigned
- Assignee changed from nobu (Nobuyoshi Nakada) to nagachika (Tomoyuki Chikanaga)
Updated by Hanmac (Hans Mackowiak) over 11 years ago
moment ... i thought thats FNM_DOTMATCH for so glob("") does not include the .git dir, but glob("",File::FNM_DOTMATCH) does ... i thought this was a feature and not a bug
Updated by nagachika (Tomoyuki Chikanaga) over 11 years ago
Hello, Hans.
After r40345, the result of Dir.glob("") don't change, but Dir.glob("/.git/config") matches "./.git/config" or so, and it is consistent with shell's behavior.
I think r40345 is appropriate bugfix.
Updated by nagachika (Tomoyuki Chikanaga) over 11 years ago
- Status changed from Assigned to Closed
This issue was solved with changeset r40394.
Gregory, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merge revision(s) 40345: [Backport #8283]
* 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]