[前][次][番号順一覧][スレッド一覧]

ruby-changes:30853

From: nobu <ko1@a...>
Date: Fri, 13 Sep 2013 16:28:30 +0900 (JST)
Subject: [ruby-changes:30853] nobu:r42932 (trunk): rbuninstall.rb: tty

nobu	2013-09-13 16:28:23 +0900 (Fri, 13 Sep 2013)

  New Revision: 42932

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42932

  Log:
    rbuninstall.rb: tty
    
    * tool/rbuninstall.rb: show progress if tty and add --tty option.

  Modified files:
    trunk/tool/rbuninstall.rb
Index: tool/rbuninstall.rb
===================================================================
--- tool/rbuninstall.rb	(revision 42931)
+++ tool/rbuninstall.rb	(revision 42932)
@@ -1,12 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/tool/rbuninstall.rb#L1
 #! /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 https://github.com/ruby/ruby/blob/trunk/tool/rbuninstall.rb#L23
 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 { https://github.com/ruby/ruby/blob/trunk/tool/rbuninstall.rb#L41
     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 { https://github.com/ruby/ruby/blob/trunk/tool/rbuninstall.rb#L61
       end
     end
   end
+  $\ = nil
+  print ors.chomp
   exit(status)
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]