brew.rb: improve handling of --version/-v option
Make both `--version` and `-v` print the Homebrew version and exit, if provided as first and sole argument. `brew --version` no longer accepts additional arguments (they were previously ignored). Otherwise interpret `brew -v <arguments>` as if `brew <arguments> -v` was executed instead (no change here), but no longer print a line with the Homebrew version. Closes Homebrew/homebrew#46790. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
This commit is contained in:
parent
85181a067f
commit
233a38ac95
@ -14,15 +14,12 @@ HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent.join("Homebrew")
|
|||||||
$:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
|
$:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
|
||||||
require "global"
|
require "global"
|
||||||
|
|
||||||
if ARGV.first == "--version"
|
if ARGV == %w[--version] || ARGV == %w[-v]
|
||||||
puts Homebrew.homebrew_version_string
|
puts "Homebrew #{Homebrew.homebrew_version_string}"
|
||||||
exit 0
|
exit 0
|
||||||
elsif ARGV.first == "-v"
|
elsif ARGV.first == "-v"
|
||||||
puts "Homebrew #{Homebrew.homebrew_version_string}"
|
|
||||||
# Shift the -v to the end of the parameter list
|
# Shift the -v to the end of the parameter list
|
||||||
ARGV << ARGV.shift
|
ARGV << ARGV.shift
|
||||||
# If no other arguments, just quit here.
|
|
||||||
exit 0 if ARGV.length == 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if OS.mac?
|
if OS.mac?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user