diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index 91901292b8..7cc493506b 100644 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -63,7 +63,7 @@ module Homebrew end # Use strings to search through the file for each string - IO.popen("strings -t x - '#{file}'", "rb") do |io| + Utils.popen_read("strings", "-t", "x", "-", file.to_s) do |io| until io.eof? str = io.readline.chomp @@ -168,8 +168,8 @@ module Homebrew prefix_check = HOMEBREW_PREFIX end - relocatable = !keg_contains(prefix_check, keg) - relocatable = !keg_contains(HOMEBREW_CELLAR, keg) && relocatable + relocatable = !keg_contains(prefix_check.to_s, keg) + relocatable = !keg_contains(HOMEBREW_CELLAR.to_s, keg) && relocatable puts if !relocatable && ARGV.verbose? rescue Interrupt ignore_interrupts { bottle_path.unlink if bottle_path.exist? } diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index fd40cf6c63..3d5959ad2f 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -27,7 +27,7 @@ class Volumes def get_mounts path=nil vols = [] # get the volume of path, if path is nil returns all volumes - raw_df = IO.popen("/bin/df -P #{path}", "rb", &:read) + raw_df = Utils.popen_read("/bin/df", "-P", path, &:read) raw_df.split("\n").each do |line| case line # regex matches: /dev/disk0s2 489562928 440803616 48247312 91% / diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index cee9f9bec5..83317af043 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -144,7 +144,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy def buffered_write(tool) target = File.basename(basename_without_params, tarball_path.extname) - IO.popen("#{tool} -f '#{tarball_path}' -c", "rb") do |pipe| + Utils.popen_read(tool, "-f", tarball_path.to_s, "-c") do |pipe| File.open(target, "wb") do |f| buf = "" f.write(buf) while pipe.read(1024, buf) diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index 36c31bd4b3..19f9bdb9c1 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -39,7 +39,7 @@ class FormulaVersions def rev_list(branch="HEAD") repository.cd do - IO.popen("git rev-list --abbrev-commit --remove-empty #{branch} -- #{entry_name}") do |io| + Utils.popen_read("git", "rev-list", "--abbrev-commit", "--remove-empty", branch, "--", entry_name) do |io| yield io.readline.chomp until io.eof? end end diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb index 0946c9215e..933a1ce736 100644 --- a/Library/Homebrew/keg_fix_install_names.rb +++ b/Library/Homebrew/keg_fix_install_names.rb @@ -86,7 +86,7 @@ class Keg end def each_unique_file_matching string - IO.popen("/usr/bin/fgrep -lr '#{string}' '#{self}' 2>/dev/null", "rb") do |io| + Utils.popen_read("/usr/bin/fgrep", "-lr", string, to_s) do |io| hardlinks = Set.new until io.eof? diff --git a/Library/Homebrew/os/mac/hardware.rb b/Library/Homebrew/os/mac/hardware.rb index a6b5ccf2ca..158e928cd8 100644 --- a/Library/Homebrew/os/mac/hardware.rb +++ b/Library/Homebrew/os/mac/hardware.rb @@ -140,10 +140,7 @@ module MacCPUs def sysctl_bool(property) (@properties ||= {}).fetch(property) do - result = nil - IO.popen("/usr/sbin/sysctl -n '#{property}' 2>/dev/null") do |f| - result = f.gets.to_i # should be 0 or 1 - end + result = Utils.popen_read("/usr/sbin/sysctl", "-n", property, &:gets).to_i # sysctl call succeded and printed 1 @properties[property] = $?.success? && result == 1 end