<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Library/Homebrew/progressbar.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -21,6 +21,9 @@
 #  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 #  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+require 'open3'
+require 'progressbar'
+
 class Tty
   class &lt;&lt;self
     def blue; bold 34; end
@@ -95,8 +98,44 @@ def safe_system cmd, *args
   raise ExecutionError.new(cmd, args, $?) unless $?.success?
 end
 
-def curl *args
-  safe_system 'curl', '-f#LA', HOMEBREW_USER_AGENT, *args unless args.empty?
+def get_size s
+  scales = {'k' =&gt; 1024, 'm' =&gt; 1024*1024}
+  scale = s[-1..-1]
+  if not scales[scale] then
+    return Integer(s)
+  end
+  return Integer(s[0..-2]) * scales[scale]
+end
+
+def curl url, *args
+  def escape(s) &quot;\&quot;#{s}\&quot;&quot; end
+  cmd = (['curl', '-fLA', escape(HOMEBREW_USER_AGENT), escape(url)] +
+         args.map {|x| escape x})
+  (stdin, stdout, stderr) = Open3.popen3(cmd.join(' '))
+
+  bar = nil
+  begin
+    loop do
+      line = stderr.readline(&quot;\r&quot;)
+      # exclude header of curl transfer info
+      next if line.strip().include? $/
+      line = line.split
+
+      # setup progress bar if total size already known
+      if not bar then
+        total = get_size(line[1])
+        next if not total &gt; 0
+        title = url.split('/')[-1]
+        bar = ProgressBar.new(title, total)
+        bar.file_transfer_mode
+      end
+
+      # update progress bar
+      size = get_size(line[3])
+      bar.set(size)
+    end
+  rescue EOFError
+  end
 end
 
 def puts_columns items, cols = 4</diff>
      <filename>Library/Homebrew/utils.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3414210a7490f37c42ba0cccee3e564b9aacd1cb</id>
    </parent>
  </parents>
  <author>
    <name>Alexander Solovyov</name>
    <email>piranha@piranha.org.ua</email>
  </author>
  <url>http://github.com/piranha/homebrew/commit/21c7dc322d41e6964791bb36f713ba5d66146a4d</url>
  <id>21c7dc322d41e6964791bb36f713ba5d66146a4d</id>
  <committed-date>2009-11-14T01:33:30-08:00</committed-date>
  <authored-date>2009-10-16T03:48:37-07:00</authored-date>
  <message>better progress bar</message>
  <tree>111b612596764f81dbd0d26adf47fefcc925e60e</tree>
  <committer>
    <name>Alexander Solovyov</name>
    <email>piranha@piranha.org.ua</email>
  </committer>
</commit>
