On Tue, Nov 18, 2003 at 03:04:10AM +0900, Chad Fowler wrote:
> As posted in ruby-talk:85349, I believe there is a bug in
> FileUtils.cp's handling of copying a file onto itself.  Attached is a
> small proposed fix.

Would this be better done in copy_file()?  (There's also a small typo in
the patch - you meant 

	raise ArgumentError, "`#{s}' and `#{d}' are the same file" if (File.expand_path(src) == File.expand_path(dest))


e.g.
def copy_file( src, dest )
  src, dest = *[src,dest].collect(File.method(expand_path))
  raise ArgumentError, "`#{src}' and `#{dest}' are the same file" if src == dest
  
  File.open(src,  'rb') {|r|
  File.open(dest, 'wb') {|w|
         copy_stream r, w
  } }
end
							

Alternatively same src/dest could be checked for in fu_each_dest_src, so
that mv() and ln() also benefit?

TTFN,


Geoff.