utils/ruby.sh: rely on test_ruby's exit code
Instead of printing "true" or "false", test_ruby now returns 1 when tested Ruby is not usable and 0 if it is.
This commit is contained in:
parent
9751d3bb8c
commit
23d24dfed7
@ -4,12 +4,9 @@ test_ruby () {
|
||||
return 1
|
||||
fi
|
||||
|
||||
local ruby_status
|
||||
ruby_status=$("$1" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e \
|
||||
"puts Gem::Version.new(RUBY_VERSION.to_s.dup).to_s.split('.').first(2) == \
|
||||
Gem::Version.new('$required_ruby_version').to_s.split('.').first(2)" 2>/dev/null)
|
||||
|
||||
test "$ruby_status" = true
|
||||
"$1" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e \
|
||||
"abort if Gem::Version.new(RUBY_VERSION.to_s.dup).to_s.split('.').first(2) != \
|
||||
Gem::Version.new('$required_ruby_version').to_s.split('.').first(2)" 2>/dev/null
|
||||
}
|
||||
|
||||
setup-ruby-path() {
|
||||
@ -17,7 +14,7 @@ setup-ruby-path() {
|
||||
local vendor_ruby_path
|
||||
local vendor_ruby_latest_version
|
||||
local vendor_ruby_current_version
|
||||
local usable_ruby_version
|
||||
local usable_ruby
|
||||
# When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh)
|
||||
# also needs to be changed.
|
||||
local required_ruby_version="2.6"
|
||||
@ -75,13 +72,13 @@ If there's no Homebrew Portable Ruby available for your processor:
|
||||
|
||||
if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]]
|
||||
then
|
||||
usable_ruby_version="true"
|
||||
usable_ruby=true
|
||||
elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]] && test_ruby "$HOMEBREW_RUBY_PATH"
|
||||
then
|
||||
usable_ruby_version=true
|
||||
usable_ruby=true
|
||||
fi
|
||||
|
||||
if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$usable_ruby_version" != "true" ]]
|
||||
if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || -z $usable_ruby ]]
|
||||
then
|
||||
brew vendor-install ruby
|
||||
if [[ ! -x "$vendor_ruby_path" ]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user