# Case sensitivity in glob revisited

**URL:** <https://www.ruby-forum.com/t/case-sensitivity-in-glob-revisited/110780>\
**Category:** Ruby\
**Created:** [July 30, 2007, 9:09pm UTC](https://www.ruby-forum.com/t/case-sensitivity-in-glob-revisited/110780 "2007-07-30T21:09:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 30, 2007, 9:09pm UTC](https://www.ruby-forum.com/t/case-sensitivity-in-glob-revisited/110780/1 "2007-07-30T21:09:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 30, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/case-sensitivity-in-glob-revisited/110780/2 "2007-07-30T21:30:36Z")

</div>

On 7/30/07, Trans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 30, 2007, 9:34pm UTC](https://www.ruby-forum.com/t/case-sensitivity-in-glob-revisited/110780/3 "2007-07-30T21:34:37Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 30, 2007, 10:02pm UTC](https://www.ruby-forum.com/t/case-sensitivity-in-glob-revisited/110780/4 "2007-07-30T22:02:42Z")

</div>

On Jul 30, 12:34 pm, Nobuyoshi N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 30, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/case-sensitivity-in-glob-revisited/110780/5 "2007-07-30T23:45:03Z")

</div>

On 7/30/07, Trans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 .

Cheers  
Robert

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 30, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/case-sensitivity-in-glob-revisited/110780/6 "2007-07-30T22:05:43Z")

</div>

On Jul 30, 12:25 pm, “Robert D.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.
