Merge pull request #7686 from maxim-belkin/test_ruby_update
utils/ruby.sh: update `test-ruby` (and rename to test_ruby)
This commit is contained in:
commit
854e96c7c5
@ -1,8 +1,12 @@
|
||||
test-ruby () {
|
||||
[[ ! -x $1 ]] && { echo "false"; return 1; }
|
||||
test_ruby () {
|
||||
if [[ ! -x $1 ]]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
||||
"$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
|
||||
"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() {
|
||||
@ -10,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"
|
||||
@ -60,7 +64,7 @@ If there's no Homebrew Portable Ruby available for your processor:
|
||||
IFS=$'\n' # Do word splitting on new lines only
|
||||
for ruby_exec in $(which -a ruby) $(PATH=$HOMEBREW_PATH which -a ruby)
|
||||
do
|
||||
if [[ $(test-ruby "$ruby_exec") == "true" ]]; then
|
||||
if test_ruby "$ruby_exec"; then
|
||||
HOMEBREW_RUBY_PATH=$ruby_exec
|
||||
break
|
||||
fi
|
||||
@ -71,13 +75,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"
|
||||
elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]]
|
||||
usable_ruby=true
|
||||
elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]] && test_ruby "$HOMEBREW_RUBY_PATH"
|
||||
then
|
||||
usable_ruby_version=$(test-ruby "$HOMEBREW_RUBY_PATH")
|
||||
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