mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rbuninstall.rb: tty
* tool/rbuninstall.rb: show progress if tty and add --tty option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6217307f43
commit
24833587d3
1 changed files with 10 additions and 6 deletions
|
@ -1,12 +1,15 @@
|
||||||
#! /usr/bin/ruby -nl
|
#! /usr/bin/ruby -nl
|
||||||
BEGIN {
|
BEGIN {
|
||||||
$dryrun = false
|
$dryrun = false
|
||||||
|
$tty = STDOUT.tty?
|
||||||
until ARGV.empty?
|
until ARGV.empty?
|
||||||
case ARGV[0]
|
case ARGV[0]
|
||||||
when /\A--destdir=(.*)/
|
when /\A--destdir=(.*)/
|
||||||
$destdir = $1
|
$destdir = $1
|
||||||
when /\A-n\z/
|
when /\A-n\z/
|
||||||
$dryrun = true
|
$dryrun = true
|
||||||
|
when /\A--(?:no-)?tty\z/
|
||||||
|
$tty = !$1
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -20,10 +23,10 @@ $_ = File.join($destdir, $_) if $destdir
|
||||||
list << $_
|
list << $_
|
||||||
END {
|
END {
|
||||||
status = true
|
status = true
|
||||||
|
$\ = ors = (!$dryrun and $tty) ? "\e[K\r" : "\n"
|
||||||
$files.each do |file|
|
$files.each do |file|
|
||||||
if $dryrun
|
print "rm #{file}"
|
||||||
puts "rm #{file}"
|
unless $dryrun
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
File.unlink(file)
|
File.unlink(file)
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
|
@ -38,9 +41,8 @@ END {
|
||||||
unlink[dir] = true
|
unlink[dir] = true
|
||||||
end
|
end
|
||||||
while dir = $dirs.pop
|
while dir = $dirs.pop
|
||||||
if $dryrun
|
print "rmdir #{dir}"
|
||||||
puts "rmdir #{dir}"
|
unless $dryrun
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
begin
|
begin
|
||||||
unlink.delete(dir)
|
unlink.delete(dir)
|
||||||
|
@ -59,5 +61,7 @@ END {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
$\ = nil
|
||||||
|
print ors.chomp
|
||||||
exit(status)
|
exit(status)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue