1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool/rbuninstall.rb
normal f8d0bdedf1 tool: add descriptions and fix typos
* tool/asm_parse.rb: add description
* tool/change_maker.rb: ditto
* tool/downloader.rb: ditto
* tool/eval.rb: ditto
* tool/expand-config.rb: ditto
* tool/extlibs.rb: ditto
* tool/fake.rb: ditto
* tool/file2lastrev.rb: ditto
* tool/gem-unpack.rb: ditto
* tool/gen_dummy_probes.rb: ditto
* tool/gen_ruby_tapset.rb: ditto
* tool/generic_erb.rb: ditto
* tool/id2token.rb: ditto
* tool/ifchange: ditto
* tool/insns2vm.rb: ditto
* tool/instruction.rb: ditto
* tool/jisx0208.rb: ditto
* tool/merger.rb: ditto
* tool/mkrunnable.rb: ditto
* tool/node_name.rb: ditto
* tool/parse.rb: ditto
* tool/rbinstall.rb: ditto
* tool/rbuninstall.rb: ditto
* tool/rmdirs: ditto
* tool/runruby.rb: ditto
* tool/strip-rdoc.rb: ditto
* tool/vcs.rb: ditto
* tool/vtlh.rb: ditto
* tool/ytab.sed: ditto
* tool/enc-unicode.rb: fix typo
* tool/mk_call_iseq_optimized.rb: ditto
* tool/update-deps: ditto
  [ruby-core:76215] [Bug ]
  by Noah Gibbs <the.codefolio.guy@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-02 21:01:04 +00:00

71 lines
1.4 KiB
Ruby
Executable file

#! /usr/bin/ruby -nl
# Used by the "make uninstall" target to uninstall Ruby.
# See common.mk for more details.
BEGIN {
$dryrun = false
$tty = STDOUT.tty?
until ARGV.empty?
case ARGV[0]
when /\A--destdir=(.*)/
$destdir = $1
when /\A-n\z/
$dryrun = true
when /\A--(?:no-)?tty\z/
$tty = !$1
else
break
end
ARGV.shift
end
$dirs = []
$files = []
}
list = ($_.chomp!('/') ? $dirs : $files)
$_ = File.join($destdir, $_) if $destdir
list << $_
END {
status = true
$\ = ors = (!$dryrun and $tty) ? "\e[K\r" : "\n"
$files.each do |file|
print "rm #{file}"
unless $dryrun
begin
File.unlink(file)
rescue Errno::ENOENT
rescue
status = false
puts $!
end
end
end
unlink = {}
$dirs.each do |dir|
unlink[dir] = true
end
while dir = $dirs.pop
print "rmdir #{dir}"
unless $dryrun
begin
begin
unlink.delete(dir)
Dir.rmdir(dir)
rescue Errno::ENOTDIR
raise unless File.symlink?(dir)
File.unlink(dir)
end
rescue Errno::ENOENT, Errno::ENOTEMPTY
rescue
status = false
puts $!
else
parent = File.dirname(dir)
$dirs.push(parent) unless parent == dir or unlink[parent]
end
end
end
$\ = nil
print ors.chomp
exit(status)
}