<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -21,7 +21,6 @@
 #  (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
@@ -108,33 +107,53 @@ def get_size s
 end
 
 def curl url, *args
-  def escape(s) &quot;\&quot;#{s}\&quot;&quot; end
+  return if args.empty?
+
+  def escape(s)
+    s = s.to_str().gsub(/&quot;/, &quot;\\\&quot;&quot;)
+    &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
+         args.map {|x| escape x} +
+         ['2&gt;&amp;1'])
+  bar, error = nil, error
 
-      # update progress bar
-      size = get_size(line[3])
-      bar.set(size)
+  IO.popen(cmd.join(' ')) do |pipe|
+    begin
+      # skip first few lines until carriage return, which contain info header
+      pipe.readline(&quot;\r&quot;)
+      loop do
+        line = pipe.readline(&quot;\r&quot;)
+        if line.strip().include? $/ then
+          # some error happened because usual info line contains no newlines
+          error = line.split($/)[-1]
+          break
+        end
+        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
-  rescue EOFError
+  end
+
+  raise Interrupt, cmd[0] if $?.termsig == 2
+  unless $? == 0
+    puts &quot;Exit code: #{$?}&quot;
+    puts &quot;Actual error: #{error}&quot; if error
+    raise ExecutionError.new(cmd[0], cmd[1..cmd.length])
   end
 end
 
@@ -213,4 +232,4 @@ def nostdout
       $stdout = real_stdout
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>Library/Homebrew/utils.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ad5d41d109de6a24b0bffdeb21dc7f17cedaacf0</id>
    </parent>
  </parents>
  <author>
    <name>Alexander Solovyov</name>
    <email>piranha@piranha.org.ua</email>
  </author>
  <url>http://github.com/piranha/homebrew/commit/d1b3eee3553006dee64adce551330339bd2e4c4c</url>
  <id>d1b3eee3553006dee64adce551330339bd2e4c4c</id>
  <committed-date>2009-11-12T04:25:00-08:00</committed-date>
  <authored-date>2009-10-16T06:00:03-07:00</authored-date>
  <message>add error detection to curl wrapper</message>
  <tree>99feb1a9394f4789be5d20d9544b3328ee04e679</tree>
  <committer>
    <name>Alexander Solovyov</name>
    <email>piranha@piranha.org.ua</email>
  </committer>
</commit>
