From cb681ffff68fad666a47ab0aca1338fa39a2e80c Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Thu, 22 Sep 2011 16:09:44 -0700 Subject: 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. --- Library/Homebrew/formula_installer.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 989bf565e..d250f16d2 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -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 -- cgit v1.2.3