mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Correct --prefix behaviour
This commit is contained in:
parent
a0920e4360
commit
ad153ad1cf
27
bin/brew
27
bin/brew
@ -157,27 +157,6 @@ def lnd keg, start
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def prefix
|
|
||||||
# Get the clean path to $prefix/Cellar/homebrew/brew/../../../
|
|
||||||
# Don't resolve any symlinks of that final result.
|
|
||||||
# Rationale: if the user calls /usr/local/bin/brew but that will resolve
|
|
||||||
# to /Brewery/Cellar/homebrew/brew we should give /usr/local and not
|
|
||||||
# /Brewery because the user probably has chosen /usr/local as the Homebrew
|
|
||||||
# to expose to the system.
|
|
||||||
if File.symlink? __FILE__
|
|
||||||
# using pathname as it will handle readlink returning abs or rel paths
|
|
||||||
d=Pathname.new(__FILE__).dirname
|
|
||||||
File.expand_path(d+File.readlink(__FILE__)+'../../../')
|
|
||||||
else
|
|
||||||
# Dir.pwd resolves the symlink :P #rubysucks
|
|
||||||
# we use the cwd because __FILE__ can be relative and expand_path
|
|
||||||
# resolves the symlink for the working directory if fed a relative path
|
|
||||||
# SIGH
|
|
||||||
cwd=Pathname.new `pwd`.strip
|
|
||||||
File.expand_path(cwd+__FILE__+'../../../')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def usage
|
def usage
|
||||||
name=File.basename $0
|
name=File.basename $0
|
||||||
<<-EOS
|
<<-EOS
|
||||||
@ -196,7 +175,11 @@ begin
|
|||||||
when 'prune'
|
when 'prune'
|
||||||
puts "Pruned #{prune} files"
|
puts "Pruned #{prune} files"
|
||||||
when '--prefix'
|
when '--prefix'
|
||||||
puts prefix
|
# we use the cwd because __FILE__ can be relative and expand_path
|
||||||
|
# resolves the symlink for the working directory if fed a relative path
|
||||||
|
# NOTE we don't use Dir.pwd because it resolves the symlink :P #rubysucks
|
||||||
|
cwd=Pathname.new `pwd`.strip
|
||||||
|
puts File.expand_path(cwd+__FILE__+'../../')
|
||||||
when '--cache'
|
when '--cache'
|
||||||
puts File.expand_path('~/Library/Application Support/Homebrew')
|
puts File.expand_path('~/Library/Application Support/Homebrew')
|
||||||
when '-h', '--help', '--usage', '-?'
|
when '-h', '--help', '--usage', '-?'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user