From 15dbb0be58b90d2271e02854bdfe143f8280e79c Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Tue, 8 Dec 2020 18:05:28 -0600 Subject: [PATCH] utils/ruby.sh: simplify and fix Ruby-related logic General: - Rename `unusable_ruby` to `need_vendored_ruby` (due to code changes). **`setup-ruby-path`** function: - Move `-z "$HOMEBREW_RUBY_PATH"` and `-n "$HOMEBREW_FORCE_VENDOR_RUBY"` checks to `need_vendored_ruby`. **`need_vendored_ruby`** function: - Check `HOMEBREW_FORCE_VENDOR_RUBY` first so that it's respected even on Macs that are "new enough" (`HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH` is set). - Don't check `-n $HOMEBREW_RUBY_PATH` because it is implicitly tested by `test_ruby`. - Remove (now-) redundant `-z $HOMEBREW_FORCE_VENDOR_RUBY` check as it is tested earlier in the conditional. --- Library/Homebrew/utils/ruby.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/utils/ruby.sh b/Library/Homebrew/utils/ruby.sh index a8ad247e15..04d91bfcb7 100644 --- a/Library/Homebrew/utils/ruby.sh +++ b/Library/Homebrew/utils/ruby.sh @@ -28,12 +28,14 @@ find_ruby() { fi } -unusable_ruby() { - if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]] +need_vendored_ruby() { + if [[ -n "$HOMEBREW_FORCE_VENDOR_RUBY" ]] + then + return 0 + elif [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]] then return 1 - elif [[ -z "$HOMEBREW_MACOS" && -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]] && - test_ruby "$HOMEBREW_RUBY_PATH" + elif [[ -z "$HOMEBREW_MACOS" ]] && test_ruby "$HOMEBREW_RUBY_PATH" then return 1 else @@ -93,7 +95,7 @@ If there's no Homebrew Portable Ruby available for your processor: fi else HOMEBREW_RUBY_PATH=$(find_ruby) - if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" ]] || unusable_ruby + if need_vendored_ruby then brew vendor-install ruby || odie "$install_fail" HOMEBREW_RUBY_PATH="$vendor_ruby_path"