Forum: Ruby Case sensitivity in glob revisited

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-07-30 21:09
(Received via mailing list)
Dir.glob( pattern, [flags] ) => array
     Dir.glob( pattern, [flags] ) {| filename | block }  => nil
------------------------------------------------------------------------
     Returns the filenames found by expanding _pattern_ which is an
     +Array+ of the patterns or the pattern +String+, either as an
     _array_ or as parameters to the block. Note that this pattern is
     not a regexp (it's closer to a shell glob). See +File::fnmatch+
for
     the meaning of the _flags_ parameter. Note that case sensitivity
     depends on your system (so +File::FNM_CASEFOLD+ is ignored)

"case sensitivity depends on your system"

Ruby's cross-platform, so Ruby should trump the system. Of course if
the system is case insensitive, to won't matter wither way. But
otherwise without this, to get case insensitivity we have to do:

  Dir.glob("[Ss][Oo][Mm][Ee][Th][Ii][Nn][Gg][Ss][Tt][Uu][Pp][Ii][Dd]")

T.
703fbc991fd63e0e1db54dca9ea31b53?d=identicon&s=25 Robert Dober (Guest)
on 2007-07-30 21:30
(Received via mailing list)
On 7/30/07, Trans <transfire@gmail.com> wrote:
>
> "case sensitivity depends on your system"
>
> Ruby's cross-platform, so Ruby should trump the system. Of course if
> the system is case insensitive, to won't matter wither way. But
> otherwise without this, to get case insensitivity we have to do:
>
>   Dir.glob("[Ss][Oo][Mm][Ee][Th][Ii][Nn][Gg][Ss][Tt][Uu][Pp][Ii][Dd]")
>
Tom what would you expect it to do in the following case:

touch SomeThingStupid
touch somethingstupid
touch SOMETHINGSTUPID  # no, I am not shouting, sorry ;)

I am afraid Ruby can not overcome some limitations of the cruel,
physical world :(.

Cheers
Robert
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (Guest)
on 2007-07-30 21:34
(Received via mailing list)
Hi,

At Tue, 31 Jul 2007 04:08:49 +0900,
Trans wrote in [ruby-talk:262505]:
>      not a regexp (it's closer to a shell glob). See +File::fnmatch+ for
>      the meaning of the _flags_ parameter. Note that case sensitivity
>      depends on your system (so +File::FNM_CASEFOLD+ is ignored)

> Ruby's cross-platform, so Ruby should trump the system. Of course if
> the system is case insensitive, to won't matter wither way. But
> otherwise without this, to get case insensitivity we have to do:
>
   Dir.glob("somehingstupid", File::FNM_CASEFOLD)
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-07-30 22:02
(Received via mailing list)
On Jul 30, 12:34 pm, Nobuyoshi Nakada <n...@ruby-lang.org> wrote:
> > otherwise without this, to get case insensitivity we have to do:
>
>    Dir.glob("somehingstupid", File::FNM_CASEFOLD)

Yea it works now! |-)  So the docs just need to catch up to reality.
Okay.

Sorry for the noise,
T.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-07-30 22:05
(Received via mailing list)
On Jul 30, 12:25 pm, "Robert Dober" <robert.do...@gmail.com> wrote:
> >      the meaning of the _flags_ parameter. Note that case sensitivity
> Tom what would you expect it to do in the following case:
>
> touch SomeThingStupid
> touch somethingstupid
> touch SOMETHINGSTUPID  # no, I am not shouting, sorry ;)
>
> I am afraid Ruby can not overcome some limitations of the cruel,
> physical world :(.

Oh, I just meant for Dir#glob. Where the docs said "(so
+File::FNM_CASEFOLD+ is ignored)" -- I didn't want it to be ignored.

T.
703fbc991fd63e0e1db54dca9ea31b53?d=identicon&s=25 Robert Dober (Guest)
on 2007-07-30 23:45
(Received via mailing list)
On 7/30/07, Trans <transfire@gmail.com> wrote:
> > >      _array_ or as parameters to the block. Note that this pattern is
> >
>
> Oh, I just meant for Dir#glob. Where the docs said "(so
> +File::FNM_CASEFOLD+ is ignored)" -- I didn't want it to be ignored.
so you would just get three entries with the same name, right?
Sorry I failed to understand that this was what you wanted <blush>.

Cheers
Robert
This topic is locked and can not be replied to.