Merge pull request #1273 from jawshooah/fix-relocate
keg_relocate: fix for multiline /usr/bin/file output
This commit is contained in:
commit
8efb585684
@ -72,7 +72,7 @@ class Keg
|
|||||||
# file with that fix is only available in macOS Sierra.
|
# file with that fix is only available in macOS Sierra.
|
||||||
# http://bugs.gw.com/view.php?id=292
|
# http://bugs.gw.com/view.php?id=292
|
||||||
with_custom_locale("C") do
|
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.symlink?
|
||||||
next true if pn.directory?
|
next true if pn.directory?
|
||||||
next true if Metafiles::EXTENSIONS.include?(pn.extname)
|
next true if Metafiles::EXTENSIONS.include?(pn.extname)
|
||||||
@ -82,11 +82,14 @@ class Keg
|
|||||||
end
|
end
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
output, _status = Open3.capture2("/usr/bin/xargs -0 /usr/bin/file --no-dereference --brief",
|
output, _status = Open3.capture2("/usr/bin/xargs -0 /usr/bin/file --no-dereference --print0",
|
||||||
stdin_data: files.join("\0"))
|
stdin_data: files.to_a.join("\0"))
|
||||||
output.each_line.with_index do |line, i|
|
output.each_line do |line|
|
||||||
next unless line.include?("text")
|
path, info = line.split("\0")
|
||||||
text_files << files[i]
|
next unless info.to_s.include?("text")
|
||||||
|
path = Pathname.new(path)
|
||||||
|
next unless files.include?(path)
|
||||||
|
text_files << path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user