diff --git a/ChangeLog b/ChangeLog index a989b13323..8938c07bda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jun 13 22:12:32 2013 Nobuyoshi Nakada + + * lib/fileutils.rb (FileUtils#rmdir): fix traversal loop, not trying + remove same directory only. + Thu Jun 13 21:30:14 2013 Nobuyoshi Nakada * configure.in (opt-dir), tool/ifchange: get rid of "alternate value" diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 5bdeeaeb08..a23da622e8 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -273,6 +273,7 @@ module FileUtils Dir.rmdir(dir = remove_tailing_slash(dir)) if parents until (parent = File.dirname(dir)) == '.' or parent == dir + dir = parent Dir.rmdir(dir) end end diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index 4ad959a32f..1317a5b043 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -1239,6 +1239,7 @@ class TestFileUtils assert_nothing_raised(Errno::ENOENT) { rmdir(subdir, parents: true) } + assert_file_not_exist(subdir) assert_file_not_exist('data/sub') assert_directory('data') end