aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorTim D. Smith2017-04-02 08:17:07 -0700
committerTim D. Smith2017-04-02 08:17:07 -0700
commit51c4c84a3f39a64d4694beebd15952d2cf1ae664 (patch)
treebe44e6aa9da4888b3329ccac188f9d10569e99c1 /Library
parent974b5e2fa26a162d29f97e996eb687b12a46a952 (diff)
downloadbrew-51c4c84a3f39a64d4694beebd15952d2cf1ae664.tar.bz2
Don't follow symlinks when hunting for strings
When we're assessing whether a bottle is relocatable, we shouldn't have to descend into symlink paths we encounter. This is supposed to be the default behavior but it doesn't appear to be (perhaps because we pass a symlink to the keg on the command line?). All of the switches that control this behavior differ between BSD and GNU grep, so sniff the grep flavor first.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/keg_relocate.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb
index 834cda768..00e941ce2 100644
--- a/Library/Homebrew/keg_relocate.rb
+++ b/Library/Homebrew/keg_relocate.rb
@@ -97,7 +97,12 @@ class Keg
end
def each_unique_file_matching(string)
- Utils.popen_read("/usr/bin/fgrep", "-lr", string, to_s) do |io|
+ bsd = `/usr/bin/fgrep -V`.include?("BSD grep")
+ grep_args = "-lr"
+ # Don't recurse into symlinks; the man page says this is the default, but
+ # it's wrong.
+ grep_args += "O" if bsd
+ Utils.popen_read("/usr/bin/fgrep", grep_args, string, to_s) do |io|
hardlinks = Set.new
until io.eof?