[#23231] What do you think about changing the return value of Kernel#require and Kernel#load to the source encoding of the required file? — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...>

Dear Ruby developers and users!

8 messages 2009/04/17

[#23318] [Feature #1408] 0.1.to_r not equal to (1/10) — Heesob Park <redmine@...>

Feature #1408: 0.1.to_r not equal to (1/10)

19 messages 2009/04/26

[ruby-core:23164] [Bug #1366] Pathname#relative_path_from should handle the scenario where the argument uses a different case for the Windows drive letter

From: Shri Borde <redmine@...>
Date: 2009-04-08 17:40:27 UTC
List: ruby-core #23164
Bug #1366: Pathname#relative_path_from should handle the scenario where the argument uses a different case for the Windows drive letter
http://redmine.ruby-lang.org/issues/show/1366

Author: Shri Borde
Status: Open, Priority: Normal
ruby -v: 1.9.1p0

On Windows, the case of the drive letter can be either upper case or lower case (eg, "C:" or "c:") on the same machine at the same time in different Command Prompt Windows (see below for details). Dir.pwd will return either lower-case or upper-case for the drive letter (“C:/” or “c:/”) depending on the Command Prompt it is run from. However, __FILE__ always uses lower-case drive letter. This can cause an ArgumentError when comparing Dir.pwd and __FILE__ using Pathname#relative_path_from. This happens with version 1.9.1p0 as well. Pathname#relative_path_from should deal with the case where the case of the argument is different.

Here is the result when running from a Command Prompt which is using capital case for the drive letter as can be seen from the prompt "C:\Users\sborde".

C:\Users\sborde> cat c:\bugs\rb1.rb
require 'pathname'
Pathname.new(Dir.pwd).relative_path_from(Pathname.new(__FILE__))

C:\Users\sborde> c:\Ruby\bin\ruby.exe c:\bugs\test.rb
c:/Ruby/lib/ruby/1.8/pathname.rb:709:in `relative_path_from': different prefix:
"C:/" and "c:/bugs/test.rb" (ArgumentError)
        from c:/bugs/test.rb:2

Here are the steps to get two Command Prompts with different cases for the drive letter:
1. Create two shortcuts on the Desktop pointing to "c:\Windows\system32\cmd.exe"
2. Right-click to change the properties.
3. For one of the shortcuts, set the "Start in" folder to "C:\" (upper case). For the other one, set it to "c:\" (lower case).
4. Double the click the shortcuts
5. Observe that the prompt in the first one is "C:\>" (upper case), and "c:\" (lower case) in the second one.
6. Run test.rb shown above from both Command Prompts. An ArgumentError will be thrown from the first Command Prompt with the upper case prompt.


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next