Bug #8597
closedUnexpected result of Dir.glob of '<' or '>' on Windows
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 @ rb_file_s_stat - >>.rb
from (irb):10:in stat' from (irb):10 from c:/usr/bin/irb.bat:18:in
'
Updated by nobu (Nobuyoshi Nakada) almost 11 years 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 (do_stat): use rb_w32_ustati64() in win32.c to get rid of
mysterious behavior of FindFirstFile() Windows API which treat "<"
and ">" like as wildcard characters. [ruby-core:55764] [Bug #8597]