summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-13 07:28:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-13 07:28:23 +0000
commit24833587d378ea690b5d91c18a8b2f4c0754696d (patch)
tree520701fb8db147bc2065722ffec4162ef4d45616
parent6217307f436172aaa6ac466736913ba87f61575d (diff)
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
-rwxr-xr-xtool/rbuninstall.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/tool/rbuninstall.rb b/tool/rbuninstall.rb
index d04800b..1a11766 100755
--- a/tool/rbuninstall.rb
+++ b/tool/rbuninstall.rb
@@ -1,12 +1,15 @@
#! /usr/bin/ruby -nl
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
@@ -20,10 +23,10 @@ $_ = File.join($destdir, $_) if $destdir
list << $_
END {
status = true
+ $\ = ors = (!$dryrun and $tty) ? "\e[K\r" : "\n"
$files.each do |file|
- if $dryrun
- puts "rm #{file}"
- else
+ print "rm #{file}"
+ unless $dryrun
begin
File.unlink(file)
rescue Errno::ENOENT
@@ -38,9 +41,8 @@ END {
unlink[dir] = true
end
while dir = $dirs.pop
- if $dryrun
- puts "rmdir #{dir}"
- else
+ print "rmdir #{dir}"
+ unless $dryrun
begin
begin
unlink.delete(dir)
@@ -59,5 +61,7 @@ END {
end
end
end
+ $\ = nil
+ print ors.chomp
exit(status)
}