aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorCharlie Sharpsteen2011-09-22 16:09:44 -0700
committerCharlie Sharpsteen2011-11-13 12:14:55 -0800
commitf5c9333a0d42e86ac82fedfeefd89a1f18772629 (patch)
tree4920a11fb9f3a0cfa19189703d134f1f21c66605 /Library/Homebrew
parent25da8e726c71af510d9bf00a79cb00e6a4fcf4bb (diff)
downloadhomebrew-f5c9333a0d42e86ac82fedfeefd89a1f18772629.tar.bz2
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 #7724.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/formula_installer.rb20
1 files changed, 19 insertions, 1 deletions
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