aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-10-12 19:08:10 +0100
committerGitHub2016-10-12 19:08:10 +0100
commit8efb585684cad75a0fd0eb531f94f80818ecb1d0 (patch)
tree78bffcef7e381486e33891c419b6061f4594585a /Library
parentfd0dffdd778370c2ab2a6b3e03a28ba0e1cc2d8a (diff)
parent24c2d0b3c2f7955f8efca4017c5cc08ede540b06 (diff)
downloadbrew-8efb585684cad75a0fd0eb531f94f80818ecb1d0.tar.bz2
Merge pull request #1273 from jawshooah/fix-relocate
keg_relocate: fix for multiline /usr/bin/file output
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/keg_relocate.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb
index 47e24cb16..ab037da98 100644
--- a/Library/Homebrew/keg_relocate.rb
+++ b/Library/Homebrew/keg_relocate.rb
@@ -72,7 +72,7 @@ class Keg
# file with that fix is only available in macOS Sierra.
# http://bugs.gw.com/view.php?id=292
with_custom_locale("C") do
- files = path.find.reject { |pn|
+ files = Set.new path.find.reject { |pn|
next true if pn.symlink?
next true if pn.directory?
next true if Metafiles::EXTENSIONS.include?(pn.extname)
@@ -82,11 +82,14 @@ class Keg
end
false
}
- output, _status = Open3.capture2("/usr/bin/xargs -0 /usr/bin/file --no-dereference --brief",
- stdin_data: files.join("\0"))
- output.each_line.with_index do |line, i|
- next unless line.include?("text")
- text_files << files[i]
+ output, _status = Open3.capture2("/usr/bin/xargs -0 /usr/bin/file --no-dereference --print0",
+ stdin_data: files.to_a.join("\0"))
+ output.each_line do |line|
+ path, info = line.split("\0")
+ next unless info.to_s.include?("text")
+ path = Pathname.new(path)
+ next unless files.include?(path)
+ text_files << path
end
end