ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
From: sho-h@netlab•jp
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50238] [Ruby trunk Bug#13889] FileUtils.rmdir が Errno::ENOTEMPTY を無視している
Date: Mon, 11 Sep 2017 01:45:21 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-66592.20170911014520.be6c5ae157643257@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13889.20170911011049@ruby-lang.org

Issue #13889 has been updated by sho-h (Sho Hashimoto).


1.9から故意に無視するようになったようでしたので日本語リファレンスの方を修正しました。そのうちWebの方も反映されるかと思います。

* https://github.com/rurema/doctree/commit/026eb146c07aa15b2914be905d49d80ef3b1c164

----------------------------------------
Bug #13889: FileUtils.rmdir が Errno::ENOTEMPTY を無視している
https://bugs.ruby-lang.org/issues/13889#change-66592

* Author: tkubo_ncs (Takehiro KUBO)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.1.6p336 (2015-04-13 revision 50298)
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
2.1 や最新のリファレンスには FileUtils.rmdir で削除対象のディレクトリが空ではない場合は Errno::ENOTEMPTY が発生すると書かれていますが、
FileUtils.rmdir を空でないディレクトリに対して呼んでもエラーにはならず、削除もされません。

~~~
irb(main):002:0> FileUtils.mkdir("dir")
=> ["dir"]
irb(main):003:0> FileUtils.touch("dir/file")
=> ["dir/file"]
irb(main):004:0> FileUtils.rmdir("dir")
=> ["dir"]                                   #<= エラーは出ない
irb(main):005:0> File.exist?("dir")          #<= 残っている
=> true
irb(main):006:0> File.exist?("dir/file")
=> true
~~~

fileutils.rb のソースで ENOTEMPTY が rescue されているようです。(trunk でも)

~~~
def rmdir(list, options = {})
  fu_check_options options, OPT_TABLE['rmdir']
  list = fu_list(list)
  parents = options[:parents]
  fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if options[:verbose]
  return if options[:noop]
  list.each do |dir|
    begin
      Dir.rmdir(dir = remove_tailing_slash(dir))
      if parents
        until (parent = File.dirname(dir)) == '.' or parent == dir
          dir = parent
          Dir.rmdir(dir)
        end
      end
    rescue Errno::ENOTEMPTY, Errno::EEXIST, Errno::ENOENT    <= ここです
    end
  end
end
module_function :rmdir
~~~

実際無視するのが正しいならリファレンスの方を修正していただければと思います。



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2017-09-11  1:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-13889.20170911011049@ruby-lang.org>
2017-09-11  1:10 ` [ruby-dev:50236] [Ruby trunk Bug#13889] FileUtils.rmdir が Errno::ENOTEMPTY を無視している tkubo
2017-09-11  1:45 ` sho-h [this message]
2017-09-11  2:01 ` [ruby-dev:50239] " sho-h
2017-09-11  2:42 ` [ruby-dev:50240] " tkubo
2017-09-16 14:31 ` [ruby-dev:50249] [Ruby trunk Bug#13889][Open] " nagachika00
2017-12-06  5:23 ` [ruby-dev:50337] [Ruby trunk Bug#13889][Closed] " nagachika00
2018-01-17 16:54 ` [ruby-dev:50416] [Ruby trunk Bug#13889] " v.ondruch
2018-08-22 14:46 ` [ruby-dev:50621] " stefan.rusterholz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-66592.20170911014520.be6c5ae157643257@ruby-lang.org \
    --to=ruby-dev@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).