diff options
| author | Jack Nagel | 2015-01-05 10:46:14 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2015-01-05 10:46:14 -0500 | 
| commit | 88b0232d23102257aac83391219de5fb9007e531 (patch) | |
| tree | db125038f52dad8a0db6429d643f103f89d2dcea /Library/Homebrew/download_strategy.rb | |
| parent | 7f06a11f58a3c491262f693f613036ae7df4870b (diff) | |
| download | homebrew-88b0232d23102257aac83391219de5fb9007e531.tar.bz2 | |
Avoid shell quoting issues when extracting xz and lz archives
Diffstat (limited to 'Library/Homebrew/download_strategy.rb')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index e3db1e914..36c96acb4 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -174,10 +174,10 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy        with_system_path { safe_system 'tar', 'xf', cached_location }        chdir      when :xz -      with_system_path { safe_system "#{xzpath} -dc \"#{cached_location}\" | tar xf -" } +      with_system_path { pipe_to_tar(xzpath) }        chdir      when :lzip -      with_system_path { safe_system "#{lzippath} -dc \"#{cached_location}\" | tar xf -" } +      with_system_path { pipe_to_tar(lzippath) }        chdir      when :xar        safe_system "/usr/bin/xar", "-xf", cached_location @@ -200,6 +200,15 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy      end    end +  def pipe_to_tar(tool) +    Utils.popen_read(tool, "-dc", cached_location.to_s) do |rd| +      Utils.popen_write("tar", "xf", "-") do |wr| +        buf = "" +        wr.write(buf) while rd.read(16384, buf) +      end +    end +  end +    # gunzip and bunzip2 write the output file in the same directory as the input    # file regardless of the current working directory, so we need to write it to    # the correct location ourselves. | 
