Dir.glob and File.fnmatch

Hi,

I always thought that the arguments to Dir.glob(...) and
File.fnmatch(...) are the same. However, with the first I can use
braces, with File.fnmatch not!

irb(main):001:0> Dir['*']
=> ["src", "plugin"]
irb(main):002:0> Dir.glob('s{rc}')
=> ["src"]
irb(main):003:0> File.fnmatch('s{rc}','src')
=> false

Is it somehow possible to use braces with File.fnmatch(...)?

Thomas

···

--

\ Thomas Leitner -- thomas [underscore] leitner [at] gmx [dot] at

/ "Life is what happens to you while you're busy making other plans"

Hi,

At Sun, 8 May 2005 23:46:18 +0900,
Thomas Leitner wrote in [ruby-talk:141672]:

I always thought that the arguments to Dir.glob(...) and
File.fnmatch(...) are the same. However, with the first I can use
braces, with File.fnmatch not!

Brace Expansion is different from Pathname Expansion.

···

--
Nobu Nakada

Yes, PickaxeII contains a better explanation than ri and effectively differentiate the semantics between the two: "Because fnmatch is implemented by the underlying operating system, it may have different semantics to Dir.glob." ==> ie: braces are not used to delimit patterns to match.

IMHO ri description needs to be slightly enhanced.

HTH
Giuliano

···

nobu.nokada@softhome.net wrote:

Hi,

At Sun, 8 May 2005 23:46:18 +0900,
Thomas Leitner wrote in [ruby-talk:141672]:

I always thought that the arguments to Dir.glob(...) and
File.fnmatch(...) are the same. However, with the first I can use
braces, with File.fnmatch not!

Brace Expansion is different from Pathname Expansion.

--
If you want to send me an email address should be 'p', then a dot, followed by 'bossi' at 'quinary', another dot and 'com' at last

Thanks for the answers! So I will stick to Dir.glob for the time being.

Thomas