ruby-changes:30852
From: nobu <ko1@a...>
Date: Fri, 13 Sep 2013 16:24:55 +0900 (JST)
Subject: [ruby-changes:30852] nobu:r42931 (trunk): rbuninstall.rb: rmdir -p
nobu 2013-09-13 16:24:48 +0900 (Fri, 13 Sep 2013) New Revision: 42931 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42931 Log: rbuninstall.rb: rmdir -p * tool/rbuninstall.rb: remove parent directories. Modified files: trunk/tool/rbuninstall.rb Index: tool/rbuninstall.rb =================================================================== --- tool/rbuninstall.rb (revision 42930) +++ tool/rbuninstall.rb (revision 42931) @@ -20,15 +20,10 @@ $_ = File.join($destdir, $_) if $destdir https://github.com/ruby/ruby/blob/trunk/tool/rbuninstall.rb#L20 list << $_ END { status = true - if $dryrun - $files.each do |file| + $files.each do |file| + if $dryrun puts "rm #{file}" - end - $dirs.reverse_each do |dir| - puts "rmdir #{dir}" - end - else - $files.each do |file| + else begin File.unlink(file) rescue Errno::ENOENT @@ -37,9 +32,18 @@ END { https://github.com/ruby/ruby/blob/trunk/tool/rbuninstall.rb#L32 puts $! end end - $dirs.reverse_each do |dir| + end + unlink = {} + $dirs.each do |dir| + unlink[dir] = true + end + while dir = $dirs.pop + if $dryrun + puts "rmdir #{dir}" + else begin begin + unlink.delete(dir) Dir.rmdir(dir) rescue Errno::ENOTDIR raise unless File.symlink?(dir) @@ -49,6 +53,9 @@ END { https://github.com/ruby/ruby/blob/trunk/tool/rbuninstall.rb#L53 rescue status = false puts $! + else + parent = File.dirname(dir) + $dirs.push(parent) unless parent == dir or unlink[parent] end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/