Project

General

Profile

Actions

Bug #4404

closed

Make Dir.glob respect backslash as if slash in windows

Added by rogerdpack (Roger Pack) about 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
Backport:
[ruby-core:35265]

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

Actions #1

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

Actions #2

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

Actions #3

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

Actions #4

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#[].

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0