Skip to content

Commit

Permalink
Fix incompatibility with zsh (mkdir error)
Browse files Browse the repository at this point in the history
* Unlike bash, zsh creates undeclared parameters on export
* Exporting undeclared GEM_HOME causes gem env gemdir to return blank
* rvm_ruby_gem_home is then set blank
* mkdir -p "$rvm_ruby_gem_home" (gemset_select) fails
  • Loading branch information
teleological committed Oct 21, 2010
1 parent 1cd2432 commit 21d6083
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/cli
Expand Up @@ -643,7 +643,7 @@ rvm()

rvm_action="${rvm_action:-usage}"

export BUNDLE_PATH GEM_HOME GEM_PATH rvm_action rvm_archflags rvm_bin_flag rvm_bin_path rvm_clang_flag rvm_configure_flags rvm_debug_flag rvm_delete_flag rvm_docs_type rvm_dump_environment_flag rvm_error_message rvm_file_name rvm_gemdir_flag rvm_gemset_name rvm_head_flag rvm_install_arguments rvm_install_on_use_flag rvm_interactive_flag rvm_llvm_flag rvm_loaded_flag rvm_make_flags rvm_niceness rvm_only_path_flag rvm_parse_break rvm_patch_names rvm_patch_original_pwd rvm_pretty_print_flag rvm_prior_cc rvm_proxy rvm_quiet_flag rvm_ree_options rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_aliases rvm_ruby_args rvm_ruby_file rvm_ruby_gem_home rvm_ruby_interpreter rvm_ruby_load_path rvm_ruby_make rvm_ruby_make_install rvm_ruby_patch_level rvm_ruby_repo_url rvm_ruby_require rvm_ruby_string rvm_ruby_strings rvm_ruby_version rvm_script_name rvm_sdk rvm_silent_flag rvm_system_flag rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_wrapper_name
__rvm_export_if_set BUNDLE_PATH GEM_HOME GEM_PATH rvm_action rvm_archflags rvm_bin_flag rvm_bin_path rvm_clang_flag rvm_configure_flags rvm_debug_flag rvm_delete_flag rvm_docs_type rvm_dump_environment_flag rvm_error_message rvm_file_name rvm_gemdir_flag rvm_gemset_name rvm_head_flag rvm_install_arguments rvm_install_on_use_flag rvm_interactive_flag rvm_llvm_flag rvm_loaded_flag rvm_make_flags rvm_niceness rvm_only_path_flag rvm_parse_break rvm_patch_names rvm_patch_original_pwd rvm_pretty_print_flag rvm_prior_cc rvm_proxy rvm_quiet_flag rvm_ree_options rvm_reload_flag rvm_remove_flag rvm_ruby_alias rvm_ruby_aliases rvm_ruby_args rvm_ruby_file rvm_ruby_gem_home rvm_ruby_interpreter rvm_ruby_load_path rvm_ruby_make rvm_ruby_make_install rvm_ruby_patch_level rvm_ruby_repo_url rvm_ruby_require rvm_ruby_string rvm_ruby_strings rvm_ruby_version rvm_script_name rvm_sdk rvm_silent_flag rvm_system_flag rvm_token rvm_trace_flag rvm_use_flag rvm_user_flag rvm_verbose_flag rvm_wrapper_name

case "$rvm_action" in
use) __rvm_use ;;
Expand Down
2 changes: 1 addition & 1 deletion scripts/selector
Expand Up @@ -4,7 +4,7 @@
__rvm_select()
{
# Set Variable Defaults
export GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION
__rvm_export_if_set GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION

if [[ -z "${rvm_ruby_string:-""}" ]] ; then
[[ -n "${rvm_ruby_interpreter:-""}" ]] && rvm_ruby_string="$rvm_ruby_interpreter"
Expand Down
11 changes: 11 additions & 0 deletions scripts/utility
Expand Up @@ -158,6 +158,17 @@ __rvm_quote_args()
return 0
}

__rvm_export_if_set()
{
for param_name in $*
do
eval param_value=\${"$param_name"-"__unset__"}
if [[ "$param_value" != "__unset__" ]]; then
export $1
fi
done
}

__rvm_quote_args_with_shift()
{
local shift_value="$1"; shift
Expand Down

4 comments on commit 21d6083

@wayneeseguin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will apply this but I have to tweak that function a bit.

@wayneeseguin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also wondering if there is a zsh setting that would make this unnecessary.

@teleological
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please tweak to your taste. The section for "export" in the "zshbuiltins" manpage reads in part: "If a parameter specified does not already exist, it is created in the global scope." I couldn't find any way to disable that behavior. Thanks!

@wayneeseguin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be applied in head, thanks!

Please sign in to comment.