Bug #4404
closedMake Dir.glob respect backslash as if slash in windows
Description
=begin
Hello all.
Related to
http://redmine.ruby-lang.org/issues/show/2625
I at times find myself using windows paths in glob's:
Dir[%!C:\Users\Public\Desktop*!]
But it never works, as the backslash must be (manually, or programmatically) replaced by a forward slash.
Could we get the default behavior changed for windows on this? That would be swell.
Thank you!
-r
=end
Updated by drbrain (Eric Hodel) about 13 years ago
=begin
I don't think your example string means what you think it means:
$ ruby -e 'p %!a\x65!, %q!a\x65!'
"ae"
"a\x65"
=end
Updated by nagachika (Tomoyuki Chikanaga) about 13 years ago
=begin
Hi,
You should escape backslash in double quoted string literal("" or %!!) as follows,
Dir[%!C:\Users\Public\Desktop\*!]
or you can use single-quoted string literal('' or %q!!).
Dir['C:\Users\Public\Desktop*']
=end
Updated by rogerdpack (Roger Pack) about 13 years ago
=begin
sorry for the poor example, the proposal should have been to make
Dir['C:\Users\Public\Desktop*']
work.
-r
=end
Updated by naruse (Yui NARUSE) almost 13 years ago
- Status changed from Open to Assigned
- Assignee set to usa (Usaku NAKAMURA)
Updated by usa (Usaku NAKAMURA) almost 13 years ago
- Status changed from Assigned to Rejected
\ in glob parameter has special meaning.
So, we can't treat it as directory separator.
This is described in RDoc of Dir#[].