Case-sensitivity and Dir

I agree that the situation is less than ideal but I’m not sure I’d want
silently different behaviour just because I was running on a different
OS though. Sadly both U*Xs and Win support upper and lower case file
names but only Win thinks that case doesn’t matter in a file name. I
wouldn’t like to run my script under linux and find that it didn’t find
some of the files that it did under windows. A tough call.

Doesn’t do anything for readability but
Dir["*.[xX][bB][xX]"]
will at least get you the files that you want.

I don’t understand why you’d have to normalise the case of all of your
strings though - but there again I don’t know what the purpose of your
script is.

Hope this helps,

Jon

···

-----Original Message-----
From: Jason Persampieri [mailto:jason@persampieri.net]
Sent: 05 February 2003 20:33
To: ruby-talk ML
Subject: case-sensitivity and Dir

I noticed a couple of mentions of this in the archives, but no
resolutions (or even definitive
statements).

On windows (and similar) systems, shouldn’t Dir[".xbx"] and
Dir["
.XBX"] be identical?

No big deal, I figure… I’ll just set $= to true, right? Wrong.
Apparently this doesn’t affect
whatever Dir uses to match filenames… doh!

I’d hate to think I have to make all of my strings upper|lower case…
one of the requirements of
this script is to be EXTREMELY readable… even adding that small bit of
overhead is frowned upon.

Jason


This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:



This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit


Any views or personal opinions expressed within this email may not be those of Talis Information Ltd.
The content of this email message and any files that may be attached are confidential, and for the usage of the intended recipient only. If you are not the intended recipient, then please return this message to the sender and delete it. Any use of this e-mail by an unauthorised recipient is prohibited.

“J.Hawkesworth” J.Hawkesworth@talis.com writes:

Doesn’t do anything for readability but
Dir[“*.[xX][bB][xX]”]
will at least get you the files that you want.

% touch foo.XbX
% ruby -v
ruby 1.8.0 (2003-02-06) [i386-linux]
% ruby -e ‘p Dir.glob(“*.xbx”, File::FNM_CASEFOLD)’
[“foo.XbX”]

···


eban

ruby 1.8.0 (2003-02-06) [i386-linux]
% ruby -e ‘p Dir.glob(“*.xbx”, File::FNM_CASEFOLD)’
[“foo.XbX”]

I’m assuming FNM_CASEFOLD is new to 1.8?

Chris

Hi,

···

At Thu, 6 Feb 2003 19:08:40 +0900, WATANABE Hirofumi wrote:

Doesn’t do anything for readability but
Dir[“*.[xX][bB][xX]”]
will at least get you the files that you want.

% touch foo.XbX
% ruby -v
ruby 1.8.0 (2003-02-06) [i386-linux]
% ruby -e ‘p Dir.glob(“*.xbx”, File::FNM_CASEFOLD)’
[“foo.XbX”]

I suspect that the flag should be defaulted for Dir. on
case-insensitive systems, i.e., DOSISH, classic MacOS, and
maybe VMS.


Nobu Nakada