[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

require upper/lower case filenames on a Windows box...

Stephan Kämper

2/1/2005 12:35:00 PM

Hi,

I'm running the latest one-click-installer (1.8.2-14) on a WinXP box.

With

require 'Date'

you'll likely get an error, but with

require 'date'

you won't...

[irb session begin] ------------------------------------
E:\>irb
irb(main):001:0> require 'Date'
c:/ruby/lib/ruby/1.8/Date.rb:238: warning: already initialized constant
MONTHNAMES
c:/ruby/lib/ruby/1.8/Date.rb:243: warning: already initialized constant
DAYNAMES
c:/ruby/lib/ruby/1.8/Date.rb:247: warning: already initialized constant
ABBR_MONTHNAMES
c:/ruby/lib/ruby/1.8/Date.rb:250: warning: already initialized constant
ABBR_DAYNAMES
c:/ruby/lib/ruby/1.8/Date.rb:254: warning: already initialized constant
ITALY
c:/ruby/lib/ruby/1.8/Date.rb:258: warning: already initialized constant
ENGLAND
c:/ruby/lib/ruby/1.8/Date.rb:262: warning: already initialized constant
JULIAN
c:/ruby/lib/ruby/1.8/Date.rb:266: warning: already initialized constant
GREGORIAN
NameError: undefined method `today' for `DateTime'
from c:/ruby/lib/ruby/1.8/Date.rb:1261:in `undef_method'
from c:/ruby/lib/ruby/1.8/Date.rb:1261
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require__'
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require'
from (irb):1
[irb session end] ------------------------------------




This doesn't seem to be an irb issue since running "require 'date'"
outside irb yields the same result:

E:\>ruby -v
ruby 1.8.2 (2004-12-25) [i386-mswin32]

E:\>ruby -r Date -e ''
c:/ruby/lib/ruby/1.8/date.rb:238: warning: already initialized constant
MONTHNAMES
---------------- [snipped part of the output] ----------------



BTW, on the identical hardware running Linux I get...

[stk@tao ~]$ ruby -v
ruby 1.8.2 (2004-12-25) [i686-linux]
[stk@tao ~]$ ruby -r date -e ''
[stk@tao ~]$

... no error, while 'Date' raises a file not found Error.


Aha, I think this happens: On Linux everything works fine. :-)

On Windows however, the case dependency with respect to filenames
is sub-optimal. Requiring the file with the 'correct' file name
'date' yields the expected behaviour ('require' returns false).

But requiring a slightly misspelled filename as 'Date' leads to
the following:

1. 'Date' is not found in the list of already loaded files.
2. Loading the file doesn't yield an Error - because Windows
finds 'date'.
3. Bad things happen on a Windows box, while processing that file.



Happy rubying

Stephan
2 Answers

djberg96

2/1/2005 4:21:00 PM

0


Stephan Kämper wrote:
> Hi,
>
> I'm running the latest one-click-installer (1.8.2-14) on a WinXP box.
>
> With
>
> require 'Date'
>
> you'll likely get an error, but with
>
> require 'date'

"Date" != "date", even on Win32. Plus, NTFS supports case sensitive
file names.
The error is not exactly what I would expect, though.

Dan

Austin Ziegler

2/1/2005 4:37:00 PM

0

On Wed, 2 Feb 2005 01:25:44 +0900, Daniel Berger
<djberg96@hotmail.com> wrote:
> Stephan Kämper wrote:
>> I'm running the latest one-click-installer (1.8.2-14) on a WinXP
>> box.
>>
>> With
>> require 'Date'
>> you'll likely get an error, but with
>> require 'date'
> "Date" != "date", even on Win32. Plus, NTFS supports case
> sensitive file names. The error is not exactly what I would
> expect, though.

Mmmm. Case preserving, not case sensitive. One of the things that MS
and Apple got right and Unix got wrong.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca