Issue #3178 has been updated by rico gloeckner.


After thinking and reading source again, i think the issue should be resolved entirely different.

Also, the change has been submitted by yugui in r21833, the change looks like this:

Index: lib/fileutils.rb
===================================================================
--- lib/fileutils.rb    (revision 21832)
+++ lib/fileutils.rb    (revision 21833)
@@ -258,15 +258,24 @@
   def rmdir(list, options = {})
     fu_check_options options, OPT_TABLE['rmdir']
     list = fu_list(list)
-    fu_output_message "rmdir #{list.join ' '}" if options[:verbose]
+    parents = options[:parents]
+    fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if options[:verbose]
     return if options[:noop]
     list.each do |dir|
-      Dir.rmdir dir.sub(%r</\z>, '')
+      begin
+        Dir.rmdir(dir = dir.sub(%r</\z>, ''))
+        if parents
+          until (parent = File.dirname(dir)) == '.' or parent == dir
+            Dir.rmdir(dir)
+          end
+        end
+      rescue Errno::ENOTEMPTY, Errno::ENOENT
+      end
     end
   end
   module_function :rmdir

-  OPT_TABLE['rmdir'] = [:noop, :verbose]
+  OPT_TABLE['rmdir'] = [:parents, :noop, :verbose]

   #
   # Options: force noop verbose

I understand, the reasoning is that when traversing ancestors, ACLs and containing files may forbid removing the ancestor; also when passing in a list instead of a single directory, removing the rescue might prevent removing the "rest" of the list.

so my suggestion would be to return a Hash containing the directories that could NOT be deleted, with the key being the directory and the value being the error like { "/tmp" => Errno:ENOACCESS, "~/a/" => Errno:ENOTEMPTY } or some such.





----------------------------------------
http://redmine.ruby-lang.org/issues/show/3178

----------------------------------------
http://redmine.ruby-lang.org