Case sensitivity in glob revisited

T

Trans

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.
 
R

Robert Dober

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]")
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
 
N

Nobuyoshi Nakada

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)
 
T

Trans

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)

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

Sorry for the noise,
T.
 
T

Trans

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]")

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.
 
R

Robert Dober

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]")

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.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top