Bug #8597

Unexpected result of Dir.glob of '<' or '>' on Windows

Added by Heesob Park 10 months ago. Updated 10 months ago.

[ruby-core:55764]
Status:Closed
Priority:Normal
Assignee:-
Category:-
Target version:-
ruby -v:ruby 2.1.0dev (2013-07-02 trunk 41732) [i386-mswin32_100] Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

I have found the following results of Dir.glob when containing '<' or '>' on path.

C:\Users\phasis>irb
irb(main):001:0> Dir.glob('>')
=> [">"]
irb(main):002:0> Dir.glob('<')
=> ["<"]
irb(main):003:0> Dir.glob('>><<>><<')
=> [">><<>><<"]
irb(main):004:0> Dir.glob('>>.<<')
=> [">>.<<"]
irb(main):005:0> Dir.glob('<><>.<><>')
=> ["<><>.<><>"]
irb(main):006:0> Dir.glob('a<<<')
=> ["a<<<"]
irb(main):007:0> Dir.glob('.<<<')
=> [".<<<"]
irb(main):008:0> Dir.glob('>>.rb')
=> [">>.rb"]

These results are due to a bug of stat function of Windows.

I think it would be better to raise Invalid argument error like File.stat.

irb(main):010:0> File.stat('>>.rb')
Errno::EINVAL: Invalid argument @ rbfiles_stat - >>.rb
from (irb):10:in stat'
from (irb):10
from c:/usr/bin/irb.bat:18:in
'

Associated revisions

Revision 41755
Added by Nobuyoshi Nakada 10 months ago

dir.c: get rid of FindFirstFile bug

  • dir.c (dostat): use rbw32_ustati64() in win32.c to get rid of mysterious behavior of FindFirstFile() Windows API which treat "<" and ">" like as wildcard characters. [Bug #8597]

History

#1 Updated by Nobuyoshi Nakada 10 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r41755.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


dir.c: get rid of FindFirstFile bug

  • dir.c (dostat): use rbw32_ustati64() in win32.c to get rid of mysterious behavior of FindFirstFile() Windows API which treat "<" and ">" like as wildcard characters. [Bug #8597]

Also available in: Atom PDF