[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Fileutils.cp bug?

Chad Fowler

11/17/2003 1:15:00 PM

1 Answer

Wejn

11/17/2003 2:07:00 PM

0

Hi,

On Mon, 17 Nov 2003, Chad Fowler wrote:

> I'm experiencing the following behavior in the latest CVS copy of ruby on
> both Windows and Linux. I think it's a bug.
>
> [chad@ns1 chad]$ cat test
> Goodbye Cruel World!
> [chad@ns1 chad]$ ruby -rfileutils -e 'FileUtils.cp("test", "test")'
>
> [chad@ns1 chad]$ cat test
> [chad@ns1 chad]$ ls -l test
> -rw-rw-r-- 1 chad chad 0 Nov 17 08:35 test
> [chad@ns1 chad]$
>
>
> I would suggest the following small change.
>
> Do others agree that this is a bug?

Well, I do think it's a bug ... but the patch is not enough, imho:

(5/wejn/ns) x$ echo "goodbye" > src
(5/wejn/ns) x$ ruby18 -rfileutils -e 'FileUtils.cp("src", "src")'
/usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:315:in `cp': `src' and `src' are the same file (ArgumentError)
from /usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:314:in `fu_each_src_dest'
from /usr/local/ruby-1.8.0/lib/ruby/1.8/fileutils.rb:314:in `cp'
from -e:1

... ok ... but:

(5/wejn/ns) x$ ruby18 -rfileutils -e 'FileUtils.cp("src", "./src")'
(5/wejn/ns) x$ ls -l src
-rw-r--r-- 1 wejn wejn 0 Nov 17 15:04 src

... problem :-(

What about comparation of [dev,inode] ?

Sincerely,
Michal
--
# Michal Safranek, email:
a=(("a".."z").to_a+["@","."]);p(("%b"%[0x645bbb83a6a496]
).scan(/...../).map{|x|a[Integer("0b"+x)]}.join.reverse)