Ruby 1.8.0 bugs on Dir

Okay, two separate bugs. One probably on all platforms and one more serious
one only on mswindows.

BUG 1 (MS only)

···

=====
Using the version with the automatic installer on windows and cygwin, too.

$ C:/ruby/bin/ruby -v
ruby 1.8.0 (2003-08-04) [i386-mswin32]
$ ruby -v
ruby 1.8.0 (2003-08-04) [i386-cygwin]

A simple script that returns the directory contents of a dir.

#!/usr/bin/ruby

puts ARGV[0]

Dir.foreach(ARGV[0]) { |i|
print i, " "
}

$ bug.fb C:
will instead open and list the current directory on ruby mswin32, instead of C:

$ bug.fb C:/
works fine.

Both work properly opening under ruby cygwin.

BUG 2

#!/usr/bin/ruby

puts ARGV[0]

Dir.open(ARGV[0]) { |i|
print i, " "
}

will print:
C:\ruby\learningGGA>bug2.rb C:
C:
#Dir:0x2847fa8

on any of my two ruby versions. This is inconsistent with what ri docs say it
should do.

Hi,

BUG 1 (MS only)

$ bug.fb C:
will instead open and list the current directory on ruby mswin32, instead of C:

“The current directory on ruby mswin32” is in C:? So it just
works as like as “dir C:” does.

What do you expect?

BUG 2

Dir.open(ARGV[0]) { |i|
print i, " "
}

will print:
C:\ruby\learningGGA>bug2.rb C:
C:
#Dir:0x2847fa8

on any of my two ruby versions. This is inconsistent with what ri docs say it
should do.

$ ri Dir.open
-------------------------------------------------------------- Dir::open
Dir.open( string ) => aDir
Dir.open( string ) {| aDir | block } => anObject

···

At Sat, 10 Jan 2004 18:11:38 +0900, GGarramuno wrote:

 With no block, +open+ is a synonym for +Dir::new+. If a block is
 present, it is passed _aDir_ as a parameter. The directory is
 closed at the end of the block, and +Dir::open+ returns the value
 of the block.

What and how inconsistent do you feel?


Nobu Nakada

“The current directory on ruby mswin32” is in C:? So it just
works as like as “dir C:” does.

What do you expect?

The command should indeed work as the msdos dir command, listing the contents
of the C: drive. Yet, it does not.
Passing the String “C:” to it lists not the contents of the C: drive but the
contents of the current directory in my mswin32 version of ruby. Only if I
pass “C:/” will it list the right directory.
The same version of ruby,on cygwin, works as it should, listing the contents of
C: when “C:” or “C:/” is passed to it.

What and how inconsistent do you feel?

Oops, no inconsistency. My bad.
It passes the DIR object to the block. I expected it to be a File object, just
as foreach but closing the object after, as that seemed to be much more useful
and logical.

It does:

C:\home>dir c:
Volume in drive C is Portable

Directory of C:\home

C:\home>dir c:
Volume in drive C is Portable

Directory of c:\

-austin

···

On Sun, 11 Jan 2004 03:36:41 +0900, GGarramuno wrote:

“The current directory on ruby mswin32” is in C:? So it just works as
like as “dir C:” does.

What do you expect?
The command should indeed work as the msdos dir command, listing the
contents of the C: drive. Yet, it does not.
Passing the String “C:” to it lists not the contents of the C: drive but
the contents of the current directory in my mswin32 version of ruby.
Only if I pass “C:/” will it list the right directory.
The same version of ruby,on cygwin, works as it should, listing the
contents of C: when “C:” or “C:/” is passed to it.


austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2004.01.10
* 16.48.43

GGarramuno wrote:

The command should indeed work as the msdos dir command, listing the contents
of the C: drive.

It does work as the MS-DOS dir command does: it lists the contents of
the current directory of the C: drive. The MS-DOS dir command has
worked that way for over twenty years.

The same version of ruby,on cygwin, works as it should, listing the contents of
C: when “C:” or “C:/” is passed to it.

MS-DOS and Windows (and OS/2) have the concept of a number of drives,
each one of which has a current directory of its own. Unix lacks this
concept. On a real Unix system, each physical drive (or partition)
after the boot drive is mapped onto a subdirectory. Programs see only
one single directory tree, with only one current directory, and have no
concept of drives at all.

Since Cygwin is,by definition, a fake Unix, it has to follow the same
rules as Unix. “C:” in Cygwin is just an alias to a Cygwin subdirectory
named /cygdrive/c. So “ls c:” in Cygwin does the same as “ls
/cygdrive/c”, and Ruby for Cygwin works the same way.

In short, Ruby is doing the correct MS-DOS thing in its Windows version
and the correct Unix thing in its Unix versions, including Cygwin.

···


John W. Kennedy
“But now is a new thing which is very old–
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor’s sake.”
– Charles Williams. “Judgement at Chelmsford”

Austin Ziegler austin@halostatue.ca wrote in message news:2004110165022.739336@PADD

It does:

C:\home>dir c:
Volume in drive C is Portable

Directory of C:\home

C:\home>dir c:
Volume in drive C is Portable

Directory of c:\

-austin

Err… That can’t be, as I never print anything like Volume in my code.
You seem to be running the msdos dir command, perhaps?

This is what I get with the code posted as bug.rb on windows XP:

C:\ruby\learningGGA>bug.rb C:
C:
… … whichrb.rb CVSROOT dist FOX_tut1.rb copy.png

C:\ruby\learningGGA>bug.rb C:/
C:/
MSDOS.SYS AUTOEXEC.BAK pagefile.sys AUTOEXEC.DOS CONFIG.DOS CONFIG.BAK CONFIG.SYS

It does:

C:\home>dir c:
Volume in drive C is Portable

Directory of C:\home

C:\home>dir c:
Volume in drive C is Portable

Directory of c:\

-austin

Err… Never mind. Nothing to do with ruby.
It seems to be an OS issue with cmd.exe with the machine I am on or
the installed patch of XP (It isn’t my personal box) or something
worse like a virus or trojan.
I am getting the same absolutely weird behavior with a similar Perl
script and with the MSDOS built-in dir command! Yikes!

Austin Ziegler austin@halostatue.ca wrote in message
news:2004110165022.739336@PADD

It does:

C:\home>dir c:
Volume in drive C is Portable

Directory of C:\home

C:\home>dir c:
Volume in drive C is Portable

Directory of c:\

-austin

Err… That can’t be, as I never print anything like Volume in my code.
You seem to be running the msdos dir command, perhaps?

This is what I get with the code posted as bug.rb on windows XP:

C:\ruby\learningGGA>bug.rb C:
C:
… … whichrb.rb CVSROOT dist FOX_tut1.rb copy.png

C:\ruby\learningGGA>bug.rb C:/
C:/
MSDOS.SYS AUTOEXEC.BAK pagefile.sys AUTOEXEC.DOS CONFIG.DOS CONFIG.BAK
CONFIG.SYS

Right. On DOS/Win32 if you list the directory : it lists the
contents of the current directory on drive and if you pass in
:\ it lists the root directory on drive . That is what
you are getting…

In the first example:

bug.rb C:

you are getting a list of the current directory on drive C and

bug.rb C:/

Getting a list of the root directory on drive C.

-rich

···

On Jan 10, 2004, at 9:36 PM, GGarramuno wrote:

Austin Ziegler austin@halostatue.ca wrote in message news:<200411
0165022.739336@PADD>…

It does:

C:\home>dir c:
Volume in drive C is Portable

Directory of C:\home

C:\home>dir c:
Volume in drive C is Portable

Directory of c:\

-austin

Err… That can’t be, as I never print anything like Volume in my code.
You seem to be running the msdos dir command, perhaps?

This is what I get with the code posted as bug.rb on windows XP:

You will find that the MS Dir command will also behaves this way.

C:\ruby\learningGGA>bug.rb C:
C:
. … whichrb.rb CVSROOT dist FOX_tut1.rb copy.png

This is a listing of the CURRENT directory on C: as you asked for.

C:\ruby\learningGGA>bug.rb C:/
C:/
MSDOS.SYS AUTOEXEC.BAK pagefile.sys AUTOEXEC.DOS
CONFIG.DOS CONFIG.BAK CONFIG.SYS
This is a listing of the root directory on C: as you asked for,

It is behaving as it should…(and as msdos dir does).

Having change to /program files on my C: drive, and swapped back to D:

D:\temp>dir c:
Volume in drive C has no label.
Volume Serial Number is FC35-A3C2

Directory of c:\

04/12/2003 10:02 642 scl.dat
29/12/2003 12:16 6,314 ZinioInstall.txt
04/11/2003 09:49 Documents and Settings
04/11/2003 09:50 Program Files
06/11/2003 14:49 WINNT
2 File(s) 6,956 bytes
3 Dir(s) 2,117,074,944 bytes free

D:\temp>dir c:
Volume in drive C has no label.
Volume Serial Number is FC35-A3C2

Directory of C:\Program Files

04/11/2003 09:50 .
04/11/2003 09:50 …
04/11/2003 09:50 Common Files
04/11/2003 10:00 Windows NT
big snip for space reasons…
D:\temp>dir c:

Regards

Ian

···

In message af53b0ba.0401101833.6d574150@posting.google.com, GGarramuno GGarramuno@aol.com writes

Ian - posting to a Newsgroup. Please remove everything to reply.