[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Change in Dir.glob behavior on Windows between 1.8.5 and 1.8.6

Yuri Klubakov

7/17/2007 8:17:00 PM

I've checked ruby-talk emails regarding Dir.glob and File.join but
didn't see this one reported before.

C:\> ruby --version
ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-mswin32]

C:\> irb
irb(main):001:0> Dir.glob(File.join(ENV['USERPROFILE'], '*.rnd'))
=> [C:\\Documents and Settings\\yura/putty.rnd"]

C:\> ruby --version
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]

C:\> irb
irb(main):001:0> Dir.glob(File.join(ENV['USERPROFILE'], '*.rnd'))
=> []


--
yura

5 Answers

Ronald Fischer

7/18/2007 8:30:00 AM

0

> I've checked ruby-talk emails regarding Dir.glob and File.join but
> didn't see this one reported before.
>
> C:\> ruby --version
> ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-mswin32]
>
> C:\> irb
> irb(main):001:0> Dir.glob(File.join(ENV['USERPROFILE'], '*.rnd'))
> => [C:\\Documents and Settings\\yura/putty.rnd"]
>
> C:\> ruby --version
> ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
>
> C:\> irb
> irb(main):001:0> Dir.glob(File.join(ENV['USERPROFILE'], '*.rnd'))
> => []

I could reproduce this on my system too.

Could it be that 1.8.6 Dir.glob gets upset on the spaces in
ENV['USERPROFILE']?

Ronald
--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162

Yuri Klubakov

7/18/2007 4:14:00 PM

0

On 7/18/07, Ronald Fischer <ronald.fischer@venyon.com> wrote:
> > I've checked ruby-talk emails regarding Dir.glob and File.join but
> > didn't see this one reported before.
> >
> > C:\> ruby --version
> > ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-mswin32]
> >
> > C:\> irb
> > irb(main):001:0> Dir.glob(File.join(ENV['USERPROFILE'], '*.rnd'))
> > => [C:\\Documents and Settings\\yura/putty.rnd"]
> >
> > C:\> ruby --version
> > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
> >
> > C:\> irb
> > irb(main):001:0> Dir.glob(File.join(ENV['USERPROFILE'], '*.rnd'))
> > => []
>
> I could reproduce this on my system too.
>
> Could it be that 1.8.6 Dir.glob gets upset on the spaces in
> ENV['USERPROFILE']?

No, it's File:ALT_SEPARATOR (\):

C:\> ruby --version
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]

C:\> irb
irb(main):001:0> Dir.glob(File.join(ENV['USERPROFILE'],
'*.rnd').gsub(File::ALT_SEPARATOR, File::SEPARATOR))
=> [C:/Documents and Settings/yura/putty.rnd"]
irb(main):002:0> Dir.glob(File.join(ENV['USERPROFILE'],
'*.rnd').gsub(File::SEPARATOR, File::ALT_SEPARATOR))
=> []

--
yura.

Nobuyoshi Nakada

7/18/2007 4:19:00 PM

0

Hi,

At Wed, 18 Jul 2007 17:30:17 +0900,
Ronald Fischer wrote in [ruby-talk:260407]:
> Could it be that 1.8.6 Dir.glob gets upset on the spaces in
> ENV['USERPROFILE']?

No, backslash is a special character.

--
Nobu Nakada

Yuri Klubakov

7/18/2007 10:53:00 PM

0

On 7/18/07, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
> At Wed, 18 Jul 2007 17:30:17 +0900,
> Ronald Fischer wrote in [ruby-talk:260407]:
> > Could it be that 1.8.6 Dir.glob gets upset on the spaces in
> > ENV['USERPROFILE']?
>
> No, backslash is a special character.

So, is it a "fix" or a "bug"?

What is now a portable way to do the following (does not work on
Windows any more):

Dir.glob(File.join(ENV['HOME'], '*.dat'))

--
yura

Nobuyoshi Nakada

7/19/2007 3:23:00 AM

0

Hi,

At Thu, 19 Jul 2007 07:52:50 +0900,
Yuri Klubakov wrote in [ruby-talk:260611]:
> > > Could it be that 1.8.6 Dir.glob gets upset on the spaces in
> > > ENV['USERPROFILE']?
> >
> > No, backslash is a special character.
>
> So, is it a "fix" or a "bug"?

a fix.

> What is now a portable way to do the following (does not work on
> Windows any more):
>
> Dir.glob(File.join(ENV['HOME'], '*.dat'))

Dir.glob(File.expand_path('*.dat', ENV['HOME']))

particularly for ENV['HOME']:

Dir.glob(File.expand_path('~/*.dat'))

--
Nobu Nakada