Skip to content

Commit

Permalink
utils/ruby.sh: make code more readable
Browse files Browse the repository at this point in the history
1. Repurpose 'vendor_ruby_current_version' variable:
   now this is not a pointer to a file but actual version number
2. Introduce 'vendor_ruby_latest_version' variable:
   it holds the value of the latest version of portable Ruby
  • Loading branch information
maxim-belkin committed May 21, 2020
1 parent db561eb commit 5d3456f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Library/Homebrew/utils/ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ test-ruby () {

setup-ruby-path() {
local vendor_dir
local vendor_ruby_current_version
local vendor_ruby_path
local vendor_ruby_latest_version
local vendor_ruby_current_version
local usable_ruby_version
# When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh)
# also needs to be changed.
Expand All @@ -22,8 +23,9 @@ If there's no Homebrew Portable Ruby available for your processor:
"

vendor_dir="$HOMEBREW_LIBRARY/Homebrew/vendor"
vendor_ruby_current_version="$vendor_dir/portable-ruby/current"
vendor_ruby_path="$vendor_ruby_current_version/bin/ruby"
vendor_ruby_path="$vendor_dir/portable-ruby/current/bin/ruby"
vendor_ruby_latest_version=$(<"$vendor_dir/portable-ruby-version")
vendor_ruby_current_version=$(readlink "$vendor_dir/portable-ruby/current")

unset HOMEBREW_RUBY_PATH

Expand All @@ -35,8 +37,7 @@ If there's no Homebrew Portable Ruby available for your processor:
if [[ -x "$vendor_ruby_path" ]]
then
HOMEBREW_RUBY_PATH="$vendor_ruby_path"

if [[ $(readlink "$vendor_ruby_current_version") != "$(<"$vendor_dir/portable-ruby-version")" ]]
if [[ $vendor_ruby_current_version != $vendor_ruby_latest_version ]]
then
if ! brew vendor-install ruby
then
Expand Down

0 comments on commit 5d3456f

Please sign in to comment.