formula_installer.rb: Pre-process ARGV before fork
`ARVG` is now filtered before the formula installer forks a new process. This allows a chance to do things like strip out `--HEAD` flags for formulae that weren't explicitly passed as arguments but came in as dependencies. Fixes Homebrew/homebrew#7724.
This commit is contained in:
parent
0474fa11cd
commit
cb681ffff6
@ -104,6 +104,7 @@ class FormulaInstaller
|
||||
# I'm guessing this is not a good way to do this, but I'm no UNIX guru
|
||||
ENV['HOMEBREW_ERROR_PIPE'] = write.to_i.to_s
|
||||
|
||||
args = filtered_args
|
||||
fork do
|
||||
begin
|
||||
read.close
|
||||
@ -113,7 +114,7 @@ class FormulaInstaller
|
||||
'-rbuild',
|
||||
'--',
|
||||
f.path,
|
||||
*ARGV.options_only
|
||||
*args.options_only
|
||||
rescue Exception => e
|
||||
Marshal.dump(e, write)
|
||||
write.close
|
||||
@ -234,6 +235,23 @@ class FormulaInstaller
|
||||
@show_summary_heading = true
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# This method gives us a chance to pre-process command line arguments before the
|
||||
# installer forks and `Formula.install` kicks in.
|
||||
def filtered_args
|
||||
# Did the user actually pass the formula this installer is considering on
|
||||
# the command line?
|
||||
def explicitly_requested?; ARGV.formulae.include? f end
|
||||
|
||||
args = ARGV.clone
|
||||
args.uniq! # Just in case someone was playing around...
|
||||
|
||||
%w[--HEAD --verbose -v --debug -d --interactive -i].each {|f| args.delete f} unless explicitly_requested?
|
||||
|
||||
return args
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user