Project

General

Profile

Bug #8006

Dir.glob behaves differently on 1.9.3 and 2.0

Added by gettalong (Thomas Leitner) over 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
[ruby-core:53108]

Description

=begin
While testing an application of mine with Ruby 2.0 I came across the following problem with Dir.glob where the pattern FOO/BAR/**/* does not match the directory FOO/BAR anymore because the implicit directories '.' and '..' don't get matched anymore.

Used files:

$ find data/webgen/basic_website_template/
data/webgen/basic_website_template/
data/webgen/basic_website_template/ext
data/webgen/basic_website_template/ext/init.rb
data/webgen/basic_website_template/webgen.config
data/webgen/basic_website_template/src
data/webgen/basic_website_template/src/.gitignore

With Ruby 1.9.3-p327:

1.9.3-p327 :001 > Dir.glob('data/webgen/basic_website_template/*/', File::FNM_PATHNAME|File::FNM_DOTMATCH|File::FNM_CASEFOLD)
=> ["data/webgen/basic_website_template/.", "data/webgen/basic_website_template/ext", "data/webgen/basic_website_template/ext/.", "data/webgen/basic_website_template/ext/..", "data/webgen/basic_website_template/ext/init.rb", "data/webgen/basic_website_template/..", "data/webgen/basic_website_template/webgen.config", "data/webgen/basic_website_template/src", "data/webgen/basic_website_template/src/.", "data/webgen/basic_website_template/src/..", "data/webgen/basic_website_template/src/.gitignore"]
1.9.3-p327 :003 >

With Ruby 2.0.0-p0:

2.0.0-p0 :001 > Dir.glob('data/webgen/basic_website_template/*/', File::FNM_PATHNAME|File::FNM_DOTMATCH|File::FNM_CASEFOLD)
=> ["data/webgen/basic_website_template/ext", "data/webgen/basic_website_template/ext/init.rb", "data/webgen/basic_website_template/webgen.config", "data/webgen/basic_website_template/src", "data/webgen/basic_website_template/src/.gitignore"]

=end

Associated revisions

Revision f57c988e
Added by nobu (Nobuyoshi Nakada) about 6 years ago

dir.c: DOTMATCH to current directory

  • dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH is given. [ruby-core:53108] [Bug #8006]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 43385
Added by nobu (Nobuyoshi Nakada) about 6 years ago

dir.c: DOTMATCH to current directory

  • dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH is given. [ruby-core:53108] [Bug #8006]

Revision 43385
Added by nobu (Nobuyoshi Nakada) about 6 years ago

dir.c: DOTMATCH to current directory

  • dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH is given. [ruby-core:53108] [Bug #8006]

Revision 43385
Added by nobu (Nobuyoshi Nakada) about 6 years ago

dir.c: DOTMATCH to current directory

  • dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH is given. [ruby-core:53108] [Bug #8006]

Revision 43385
Added by nobu (Nobuyoshi Nakada) about 6 years ago

dir.c: DOTMATCH to current directory

  • dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH is given. [ruby-core:53108] [Bug #8006]

Revision 43385
Added by nobu (Nobuyoshi Nakada) about 6 years ago

dir.c: DOTMATCH to current directory

  • dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH is given. [ruby-core:53108] [Bug #8006]

Revision 43385
Added by nobu (Nobuyoshi Nakada) about 6 years ago

dir.c: DOTMATCH to current directory

  • dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH is given. [ruby-core:53108] [Bug #8006]

Revision c84397f4
Added by nagachika (Tomoyuki Chikanaga) almost 6 years ago

merge revision(s) 43385: [Backport #8006]

    * dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH
      is given.  [ruby-core:53108] [Bug #8006]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

Updated by gettalong (Thomas Leitner) over 6 years ago

=begin
After some more experimenting, it seems that the '**' operator doesn't act the same like in 1.9.3:

With Ruby 2.0.0-p0:

2.0.0p0 :017 > Dir.glob('data/webgen/basic_website_template//', File::FNM_DOTMATCH|File::FNM_CASEFOLD)
=> ["data/webgen/basic_website_template/./.", "data/webgen/basic_website_template/./ext", "data/webgen/basic_website_template/./..", "data/webgen/basic_website_template/./webgen.config", "data/webgen/basic_website_template/./src", "data/webgen/basic_website_template/ext/.", "data/webgen/basic_website_template/ext/..", "data/webgen/basic_website_template/ext/init.rb", "data/webgen/basic_website_template/../.", "data/webgen/basic_website_template/../passive_sources", "data/webgen/basic_website_template/../..", "data/webgen/basic_website_template/../bundle_template_files", "data/webgen/basic_website_template/../basic_website_template", "data/webgen/basic_website_template/src/.", "data/webgen/basic_website_template/src/..", "data/webgen/basic_website_template/src/.gitignore"]
2.0.0p0 :018 > Dir.glob('data/webgen/basic_website_template/*/', File::FNM_DOTMATCH|File::FNM_CASEFOLD)
=> ["data/webgen/basic_website_template/ext", "data/webgen/basic_website_template/ext/init.rb", "data/webgen/basic_website_template/webgen.config", "data/webgen/basic_website_template/src", "data/webgen/basic_website_template/src/.gitignore"]

=end

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • Assignee set to nobu (Nobuyoshi Nakada)

Hi,

r36903 seems related with this issue.
I'm not sure it is intentional change or not.
nakada san, what do you think?

Updated by gettalong (Thomas Leitner) over 6 years ago

=begin
For your information, I have fixed this problem in my code, see the (()).

Would be good, though, to know whether this is intentional or not.

Thanks!
=end

#4

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r43385.
Thomas, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


dir.c: DOTMATCH to current directory

  • dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH is given. [ruby-core:53108] [Bug #8006]

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Backport set to 1.9.3: DONTNEED, 2.0.0: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) almost 6 years ago

  • Backport changed from 1.9.3: DONTNEED, 2.0.0: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE

r43385 was backported to uby_2_0_0 branch at r44897.

Also available in: Atom PDF