From 073685284fe3f4fc9ac2a73b3e7fd99083a0b22b Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sat, 28 Dec 2019 14:48:34 +0530 Subject: [PATCH] postinstall: Use CLI::Parser to parse args --- Library/Homebrew/formula_installer.rb | 8 +------- Library/Homebrew/postinstall.rb | 13 +++++++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index aca3adc486..c2abe1ef56 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -914,13 +914,7 @@ class FormulaInstaller -- #{HOMEBREW_LIBRARY_PATH}/postinstall.rb #{formula.path} - ].concat(ARGV.options_only) - ["--HEAD", "--devel"] - - if formula.head? - args << "--HEAD" - elsif formula.devel? - args << "--devel" - end + ] Utils.safe_fork do if Sandbox.formula?(formula) diff --git a/Library/Homebrew/postinstall.rb b/Library/Homebrew/postinstall.rb index 3498e03d69..fe4e006019 100644 --- a/Library/Homebrew/postinstall.rb +++ b/Library/Homebrew/postinstall.rb @@ -6,15 +6,24 @@ require "global" require "debrew" require "fcntl" require "socket" +require "cli/parser" + +def postinstall_args + Homebrew::CLI::Parser.new do + switch :force + switch :verbose + switch :debug + end +end begin + postinstall_args.parse error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io) error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) trap("INT", old_trap) - formula = ARGV.resolved_formulae.first - formula.extend(Debrew::Formula) if ARGV.debug? + formula = Homebrew.args.resolved_formulae.first formula.run_post_install rescue Exception => e # rubocop:disable Lint/RescueException error_pipe.puts e.to_json