Hi,

At Wed, 16 May 2007 10:03:42 +0900,
johan556 / gmail.com wrote in [ruby-core:11176]:
> Should this be considered a bug in FileUtils, or is there some reason
> why FileUtils differ in behavior?

I don't think there is such reason.

> Below I give a Ruby unit-test that illustrates the current "misfeature".

It depends on external environments, sudo command and
user/group names.  It would be good enough to change the mode
of the parent directory, I guess.


Index: lib/fileutils.rb =================================================================== --- lib/fileutils.rb (revision 12283) +++ lib/fileutils.rb (working copy) @@ -715,9 +715,9 @@ module FileUtils begin ent.remove - rescue + rescue Errno::ENOENT raise unless force end end - rescue + rescue Errno::ENOENT raise unless force end @@ -749,9 +749,9 @@ module FileUtils begin ent.remove - rescue + rescue Errno::ENOENT raise unless force end end - rescue + rescue Errno::ENOENT raise unless force end @@ -764,5 +764,5 @@ module FileUtils def remove_file(path, force = false) Entry_.new(path).remove_file - rescue + rescue Errno::ENOENT raise unless force end Index: test/fileutils/test_fileutils.rb =================================================================== --- test/fileutils/test_fileutils.rb (revision 12283) +++ test/fileutils/test_fileutils.rb (working copy) @@ -416,5 +416,5 @@ end Dir.rmdir 'tmpdatadir' - Dir.mkdir 'tmp/tmpdir' + Dir.mkdir 'tmp/tmpdir', 0700 File.open('tmp/tmpdir/a', 'w') {|f| f.puts 'dummy' } File.open('tmp/tmpdir/c', 'w') {|f| f.puts 'dummy' } @@ -422,4 +422,14 @@ end assert_file_not_exist 'tmp/tmpdir/a' assert_file_not_exist 'tmp/tmpdir/c' + File.open('tmp/tmpdir/d', 'w') {|f| f.puts 'dummy' } + File.chmod(0500, 'tmp/tmpdir') + begin + assert_file_exist 'tmp/tmpdir/d' + assert_raises(Errno::EACCES) {rm_f 'tmp/tmpdir/d'} + assert_file_exist 'tmp/tmpdir/d' + ensure + File.chmod(0700, 'tmp/tmpdir') + File.unlink 'tmp/tmpdir/d' + end Dir.rmdir 'tmp/tmpdir'
-- Nobu Nakada