Fix RVM loading with bash nounset#5657
Open
ZiPengWei wants to merge 1 commit into
Open
Conversation
Signed-off-by: 魏子堋 <506837925@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4694.
This makes the RVM load path tolerate Bash
set -u/nounset when no system metadata has been detected yet. The failing Packer/AWS scenario runs RVM from a strict-mode shell, so reads of variables such as_system_name,rvm_prefix, andchpwd_functionsshould not assume those names have already been initialized.Changes:
rvm_prefixbefore deriving it fromrvm_path._system_namehas been detected.chpwd_functionswithout triggering nounset on Bash 3.2.Validation
bash -n scripts/rvm scripts/functions/support scripts/cd tests/fast/nounset_comment_test.shbash -lc 'set -u; export rvm_path=$PWD; source scripts/rvm; rvm use system >/tmp/rvm-use-system.out; cat /tmp/rvm-use-system.out; declare -p chpwd_functions; [[ ":${SHELLOPTS:-}:" == *":nounset:"* ]]'bash -lc 'set -u; export rvm_path=$PWD; source scripts/rvm; rvm info system >/tmp/rvm-info-system.out; head -n 22 /tmp/rvm-info-system.out; [[ ":${SHELLOPTS:-}:" == *":nounset:"* ]]'git diff --checkNote: the local
rvm info systemrun on macOS emits existing environment warnings about/opt/homebrew/binpermissions and Command Line Tools vs full Xcode, but exits successfully.