From b78b823239b13766a02f1c4f6ba69254cb25f820 Mon Sep 17 00:00:00 2001 From: richo Date: Fri, 14 Dec 2012 02:18:45 +1100 Subject: [PATCH] Stub out cd with __rvm_cd Leaves CDPATH alone except when actually switching directories Also fix some unquoted paths --- binscripts/rvm-installer | 2 +- scripts/alias | 4 ++-- scripts/cli | 2 +- scripts/disk-usage | 2 +- scripts/docs | 4 ++-- scripts/fetch | 2 +- scripts/functions/cleanup | 2 +- scripts/functions/installer | 8 ++++---- scripts/functions/manage/base | 32 +++++++++++++++---------------- scripts/functions/manage/goruby | 2 +- scripts/functions/manage/ironruby | 2 +- scripts/functions/manage/jruby | 10 +++++----- scripts/functions/manage/maglev | 12 ++++++------ scripts/functions/manage/mruby | 4 ++-- scripts/functions/manage/opal | 4 ++-- scripts/functions/manage/ree | 4 ++-- scripts/functions/manage/rubinius | 2 +- scripts/functions/pkg | 12 ++++++------ scripts/functions/reset | 2 +- scripts/functions/rvmrc | 4 ++-- scripts/functions/support | 12 ++++++++++++ scripts/gemsets | 6 +++--- scripts/help | 2 +- scripts/list | 10 +++++----- scripts/migrate | 2 +- scripts/repair | 8 ++++---- scripts/rubygems | 2 +- scripts/snapshot | 8 ++++---- scripts/tools | 2 +- 29 files changed, 90 insertions(+), 78 deletions(-) diff --git a/binscripts/rvm-installer b/binscripts/rvm-installer index 798cc044c6..c007802175 100755 --- a/binscripts/rvm-installer +++ b/binscripts/rvm-installer @@ -153,7 +153,7 @@ Could not download '${_url}'. fi [[ -d "${rvm_src_path}/rvm" ]] || \mkdir -p "${rvm_src_path}/rvm" - if ! builtin cd "${rvm_src_path}/rvm" + if ! __rvm_cd "${rvm_src_path}/rvm" then log "Could not change directory '${rvm_src_path}/rvm'." return 2 diff --git a/scripts/alias b/scripts/alias index 7307b27d24..f9079c3715 100755 --- a/scripts/alias +++ b/scripts/alias @@ -184,7 +184,7 @@ alias_list() { done ;; esac < <( - chpwd_functions="" builtin cd "$rvm_rubies_path" + __rvm_cd "$rvm_rubies_path" find . -maxdepth 1 -mindepth 1 -type l | sed -e 's#.*/##' ) } @@ -193,7 +193,7 @@ alias_search_by_target() { typeset item items target search search="${alias_name}@${gemset_name}" - items=($(chpwd_functions="" builtin cd "$rvm_rubies_path" ; find . -maxdepth 1 -mindepth 1 -type l | sed -e 's#./##')) + items=($(__rvm_cd "$rvm_rubies_path" ; find . -maxdepth 1 -mindepth 1 -type l | sed -e 's#./##')) for item in "${items[@]}" do diff --git a/scripts/cli b/scripts/cli index 6600a1c231..49546c4585 100755 --- a/scripts/cli +++ b/scripts/cli @@ -939,7 +939,7 @@ Please do one of the following: ( if [[ -n "${rvm_in_flag}" && -d "${rvm_in_flag}" ]] - then chpwd_functions="" builtin cd "${rvm_in_flag}" + then __rvm_cd "${rvm_in_flag}" fi "$rvm_scripts_path/set" "$rvm_action" "${rvm_ruby_args[@]}" ) diff --git a/scripts/disk-usage b/scripts/disk-usage index b1cc12f45d..bc5d3abce5 100755 --- a/scripts/disk-usage +++ b/scripts/disk-usage @@ -72,7 +72,7 @@ case "${1:-help}" in all|total|archives|repos|sources|logs|pkg|rubies|gemsets|wrappers|tmp|others) ( export length="" - chpwd_functions="" builtin cd $rvm_path + __rvm_cd $rvm_path $1_disk_usage ) ;; diff --git a/scripts/docs b/scripts/docs index ddd9a9f33c..a7c44ab3da 100755 --- a/scripts/docs +++ b/scripts/docs @@ -67,7 +67,7 @@ generate_ri() { # Generate ri docs ( - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_docs_ruby_string/" + __rvm_cd "${rvm_src_path}/$rvm_docs_ruby_string/" rvm_log "Generating ri documentation, be aware that this could take a *long* time, and depends heavily on your system resources..." @@ -80,7 +80,7 @@ generate_ri() generate_rdoc() { ( - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_docs_ruby_string/" + __rvm_cd "${rvm_src_path}/$rvm_docs_ruby_string/" __rvm_rm_rf "${rvm_docs_path:-"$rvm_path/docs"}/$rvm_docs_ruby_string/$rvm_docs_type/" diff --git a/scripts/fetch b/scripts/fetch index 71e9479472..5170a56308 100755 --- a/scripts/fetch +++ b/scripts/fetch @@ -18,7 +18,7 @@ __rvm_cleanup_download() [[ -f "$archive" ]] && __rvm_rm_rf "$archive" } -chpwd_functions="" builtin cd "$rvm_archives_path" +__rvm_cd "$rvm_archives_path" [[ -n "$archive" ]] || archive=$(basename "$url") fetch_command="curl ${rvm_proxy:+-x}${rvm_proxy:-} -f -L --create-dirs -C - -o ${archive}" diff --git a/scripts/functions/cleanup b/scripts/functions/cleanup index 889a4e39f6..f0809e56fe 100644 --- a/scripts/functions/cleanup +++ b/scripts/functions/cleanup @@ -61,7 +61,7 @@ __rvm_reboot() if [[ "yes" == "$response" ]] then - chpwd_functions="" builtin cd $rvm_path + __rvm_cd $rvm_path command -v __rvm_reset >> /dev/null 2>&1 || \ source "$rvm_scripts_path/functions/reset" diff --git a/scripts/functions/installer b/scripts/functions/installer index 79b985edbc..c6d7cbc4ee 100644 --- a/scripts/functions/installer +++ b/scripts/functions/installer @@ -144,7 +144,7 @@ configure_installation() if [[ -d "$install_source_path/scripts" \ && -s "$install_source_path/scripts/functions/utility" ]] then - chpwd_functions="" builtin cd "$install_source_path" + __rvm_cd "$install_source_path" fi # Save scripts path @@ -313,7 +313,7 @@ setup_configuration_files() { typeset _save_dir _save_dir="$PWD" - chpwd_functions="" builtin cd "$rvm_path" + __rvm_cd "$rvm_path" if [[ -f config/user ]] then @@ -345,7 +345,7 @@ setup_configuration_files() GREP_OPTIONS="" \grep '^_' user/rvmrcs > user/rvmrcs.new || true mv user/rvmrcs.new user/rvmrcs - chpwd_functions="" builtin cd "${_save_dir}" + __rvm_cd "${_save_dir}" } ensure_scripts_are_executable() @@ -643,7 +643,7 @@ is_file_group() [[ "$(get_file_group "$1")" == "$2" ]] install_man_pages() { files=($( - chpwd_functions="" builtin cd "$install_source_path/man" + __rvm_cd "$install_source_path/man" find . -maxdepth 2 -mindepth 1 -type f -print )) diff --git a/scripts/functions/manage/base b/scripts/functions/manage/base index e206d14e97..9b0a556bae 100644 --- a/scripts/functions/manage/base +++ b/scripts/functions/manage/base @@ -43,7 +43,7 @@ __rvm_apply_patches() (( $# == 0 )) || shift _save_dir="$PWD" - chpwd_functions="" builtin cd "$source_directory" + __rvm_cd "$source_directory" case "${1:-all}" in (all) __rvm_current_patch_names patches ;; (*) patches=( "$@" ) ;; @@ -71,7 +71,7 @@ __rvm_apply_patches() result=1 fi done - chpwd_functions="" builtin cd "${_save_dir}" + __rvm_cd "${_save_dir}" return ${result:-0} } @@ -135,7 +135,7 @@ __rvm_install_source() (( rvm_ruby_selected_flag )) || __rvm_select rvm_log "Installing Ruby from source to: $rvm_ruby_home, this may take a while depending on your cpu(s)..." - chpwd_functions="" builtin cd "${rvm_src_path}" + __rvm_cd "${rvm_src_path}" if __rvm_fetch_ruby then true @@ -145,7 +145,7 @@ __rvm_install_source() return $result fi - if chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + if __rvm_cd "${rvm_src_path}/$rvm_ruby_string" then true else result=$? @@ -410,7 +410,7 @@ __rvm_fetch_from_git_revision_or_sha() [[ -n "$rvm_ruby_revision" ]] then ( - chpwd_functions="" builtin cd "${rvm_repos_path}/${rvm_ruby_interpreter}" + __rvm_cd "${rvm_repos_path}/${rvm_ruby_interpreter}" [[ "$rvm_ruby_revision" != "head" ]] || rvm_ruby_revision="master" git checkout -f "${rvm_ruby_revision}" ) @@ -418,7 +418,7 @@ __rvm_fetch_from_git_revision_or_sha() [[ -n "${rvm_ruby_sha:-}" ]] then ( - chpwd_functions="" builtin cd "${rvm_repos_path}/${rvm_ruby_interpreter}" + __rvm_cd "${rvm_repos_path}/${rvm_ruby_interpreter}" git checkout -f "${rvm_ruby_sha}" ) fi @@ -446,7 +446,7 @@ __rvm_fetch_from_github() then typeset existing_uri existing_uri="$( - chpwd_functions="" builtin cd "${rvm_repos_path}/${rvm_ruby_interpreter}" >/dev/null + __rvm_cd "${rvm_repos_path}/${rvm_ruby_interpreter}" >/dev/null git remote -v 2>/dev/null | awk '/^origin.*fetch/ {print $2}' )" if @@ -462,7 +462,7 @@ __rvm_fetch_from_github() if [[ -d "${rvm_repos_path}/${rvm_ruby_interpreter}" ]] then \rm -rf "${rvm_repos_path}/${rvm_ruby_interpreter}" fi - chpwd_functions="" builtin cd "$rvm_home" + __rvm_cd "$rvm_home" if ! __rvm_log_command "$1.repo" "Cloning $rvm_ruby_repo_url" \ git clone --depth ${rvm_git_clone_depth:-1} "$rvm_ruby_repo_url" "${rvm_repos_path}/${rvm_ruby_interpreter}" @@ -477,7 +477,7 @@ __rvm_fetch_from_github() else typeset branch branch="${rvm_ruby_repo_branch:-"master"}" - chpwd_functions="" builtin cd "${rvm_repos_path}/${rvm_ruby_interpreter}" + __rvm_cd "${rvm_repos_path}/${rvm_ruby_interpreter}" __rvm_log_command "$1.clean" "Cleaning git repo" __rvm_git_clean_repo __rvm_log_command "$1.fetch" "Fetching from origin" git fetch origin @@ -485,7 +485,7 @@ __rvm_fetch_from_github() ( remote="origin" - chpwd_functions="" builtin cd "${rvm_repos_path}/${rvm_ruby_interpreter}" + __rvm_cd "${rvm_repos_path}/${rvm_ruby_interpreter}" if [[ -z "$(git branch | awk "/$rvm_ruby_repo_branch$/")" ]] @@ -513,7 +513,7 @@ __rvm_fetch_from_github() __rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string"/.git __rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string"/.svn - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + __rvm_cd "${rvm_src_path}/$rvm_ruby_string" } __rvm_fetch_ruby() @@ -652,7 +652,7 @@ __rvm_fetch_ruby() return $? else ( - chpwd_functions="" builtin cd "${rvm_repos_path}/${rvm_ruby_interpreter}" + __rvm_cd "${rvm_repos_path}/${rvm_ruby_interpreter}" typeset current_url current_url="$(git remote -v | awk '$1=="origin" && $3=="(fetch)" {print $2}')" [[ "$current_url" == "$rvm_ruby_repo_url" ]] || git remote set-url origin "$rvm_ruby_repo_url" @@ -661,7 +661,7 @@ __rvm_fetch_ruby() # Use the selected branch. ( - chpwd_functions="" builtin cd "${rvm_repos_path}/${rvm_ruby_interpreter}" + __rvm_cd "${rvm_repos_path}/${rvm_ruby_interpreter}" remote="${remote:-origin}" branch=$(git symbolic-ref -q HEAD 2>/dev/null) @@ -740,7 +740,7 @@ __rvm_fetch_ruby() rvm_rev="-$rvm_ruby_revision" fi ( - chpwd_functions="" builtin cd "${rvm_repos_path}/${rvm_ruby_interpreter}" + __rvm_cd "${rvm_repos_path}/${rvm_ruby_interpreter}" if [[ -d "${rvm_repos_path}/${rvm_ruby_interpreter}/.svn" ]] then @@ -1074,7 +1074,7 @@ __rvm_manage_rubies() esac fi __rvm_read_lines rubies < <( - chpwd_functions="" builtin cd "$rvm_rubies_path" + __rvm_cd "$rvm_rubies_path" find . -maxdepth 1 -mindepth 1 -type d -not -newermt $_older_then 2>/dev/null | cut -c 3- ) (( ${#rubies[*]} )) || @@ -1102,7 +1102,7 @@ __rvm_manage_rubies() __rvm_ask_for "Are you SURE you wish to '$action' all rubies?" yes || return $? fi __rvm_read_lines rubies < <( - chpwd_functions="" builtin cd "$rvm_rubies_path" + __rvm_cd "$rvm_rubies_path" find . -maxdepth 1 -mindepth 1 -type d 2>/dev/null | cut -c 3- ) fi diff --git a/scripts/functions/manage/goruby b/scripts/functions/manage/goruby index 40f99f4bc6..db82030ef9 100644 --- a/scripts/functions/manage/goruby +++ b/scripts/functions/manage/goruby @@ -21,7 +21,7 @@ goruby_install() exit $result fi - #chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string/configure" + #__rvm_cd "${rvm_src_path}/$rvm_ruby_string/configure" if [[ ! -s "${rvm_src_path}/$rvm_ruby_string/configure" ]] then diff --git a/scripts/functions/manage/ironruby b/scripts/functions/manage/ironruby index b08914bd69..5957bc9a51 100644 --- a/scripts/functions/manage/ironruby +++ b/scripts/functions/manage/ironruby @@ -33,7 +33,7 @@ ironruby_install() __rvm_fetch_ruby || return $? - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + __rvm_cd "${rvm_src_path}/$rvm_ruby_string" compatible_ruby="$(__rvm_mri_ruby)" diff --git a/scripts/functions/manage/jruby b/scripts/functions/manage/jruby index ba9356caa7..ab909bb27d 100644 --- a/scripts/functions/manage/jruby +++ b/scripts/functions/manage/jruby @@ -2,7 +2,7 @@ jruby_install_build_nailgun() { - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string/tool/nailgun" && + __rvm_cd "${rvm_src_path}/$rvm_ruby_string/tool/nailgun" && case "$rvm_ruby_version" in 1.2*|1.3*) true @@ -44,11 +44,11 @@ jruby_install() esac fi - chpwd_functions="" builtin cd "${rvm_src_path}" + __rvm_cd "${rvm_src_path}" __rvm_fetch_ruby || return $? - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + __rvm_cd "${rvm_src_path}/$rvm_ruby_string" if (( ${#rvm_configure_flags[@]} || ${#rvm_patch_names[@]} || ${rvm_head_flag:-0} )) @@ -78,7 +78,7 @@ jruby_install() case ${rvm_ruby_string} in jruby-head*|jruby-1.7.*) ( - builtin cd "$rvm_ruby_home/bin/" + __rvm_cd "$rvm_ruby_home/bin/" for binary in irb ruby gem do [[ -f "${binary}" ]] || ln -fs "j${binary}" "${binary}" @@ -87,7 +87,7 @@ jruby_install() ;; *) ( - builtin cd "$rvm_ruby_home/bin/" + __rvm_cd "$rvm_ruby_home/bin/" for binary in jirb jruby jgem do ln -fs "$binary" "${binary#j}" diff --git a/scripts/functions/manage/maglev b/scripts/functions/manage/maglev index 850d040ad8..5f9089f5fc 100644 --- a/scripts/functions/manage/maglev +++ b/scripts/functions/manage/maglev @@ -16,7 +16,7 @@ maglev_install() exit $result fi - chpwd_functions="" builtin cd "${rvm_src_path}" + __rvm_cd "${rvm_src_path}" system="$(uname -s)" arch="$(uname -m)" @@ -36,7 +36,7 @@ maglev_install() if (( ${rvm_head_flag:=0} == 1 )) then - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + __rvm_cd "${rvm_src_path}/$rvm_ruby_string" rvm_gemstone_package_file="GemStone-$(GREP_OPTIONS="" \grep ^GEMSTONE version.txt | cut -f2 -d-).${system}-${arch}" @@ -54,14 +54,14 @@ maglev_install() exit $result fi - chpwd_functions="" builtin cd "${rvm_src_path}" + __rvm_cd "${rvm_src_path}" if [[ -s "$rvm_ruby_package_file" ]] then mv "$rvm_ruby_package_file" "${rvm_src_path}/$rvm_ruby_string" fi - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + __rvm_cd "${rvm_src_path}/$rvm_ruby_string" if [[ -d ${rvm_src_path}/${rvm_gemstone_package_file} ]] then @@ -93,7 +93,7 @@ maglev_install() "Installing maglev to $rvm_ruby_home" ( - chpwd_functions="" builtin cd "$rvm_ruby_home/bin/" + __rvm_cd "$rvm_ruby_home/bin/" for binary in maglev-irb maglev-ruby maglev-gem do @@ -109,7 +109,7 @@ maglev_install() __rvm_inject_gem_env "$rvm_ruby_home/bin/$binary" done - chpwd_functions="" builtin cd "$rvm_ruby_home" + __rvm_cd "$rvm_ruby_home" if (( ${rvm_head_flag:=0} == 1 )) then diff --git a/scripts/functions/manage/mruby b/scripts/functions/manage/mruby index 9f14309474..e5a609d9cf 100644 --- a/scripts/functions/manage/mruby +++ b/scripts/functions/manage/mruby @@ -23,7 +23,7 @@ mruby_install() (( rvm_ruby_selected_flag )) || __rvm_select rvm_log "Installing Ruby from source to: $rvm_ruby_home, this may take a while depending on your cpu(s)..." - chpwd_functions="" builtin cd "${rvm_src_path}" + __rvm_cd "${rvm_src_path}" if __rvm_fetch_ruby then true @@ -33,7 +33,7 @@ mruby_install() return $result fi - if chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + if __rvm_cd "${rvm_src_path}/$rvm_ruby_string" then true else result=$? diff --git a/scripts/functions/manage/opal b/scripts/functions/manage/opal index 3d2ff3daf7..bbdbae41fd 100644 --- a/scripts/functions/manage/opal +++ b/scripts/functions/manage/opal @@ -13,7 +13,7 @@ opal_install() exit $result fi - builtin cd "${rvm_src_path}" + __rvm_cd "${rvm_src_path}" system="$(uname -s)" arch=$(file `which node`) @@ -42,7 +42,7 @@ opal_install() echo "OPAL FAKE GEM COMMAND: $@" ' - builtin cd "$rvm_ruby_home/bin/" + __rvm_cd "$rvm_ruby_home/bin/" ln -fs "$opal_node_path" "ruby" echo "$opal_fake_gem_command" > "gem" echo "$opal_config" > "../config" diff --git a/scripts/functions/manage/ree b/scripts/functions/manage/ree index e9d297c7b7..612320cfb0 100644 --- a/scripts/functions/manage/ree +++ b/scripts/functions/manage/ree @@ -19,7 +19,7 @@ ree_install() then rvm_log "Installing Ruby Enterprise Edition from source to: $rvm_ruby_home" - chpwd_functions="" builtin cd "${rvm_src_path}" + __rvm_cd "${rvm_src_path}" if [[ -d "${rvm_src_path}/$rvm_ruby_string" ]] && @@ -55,7 +55,7 @@ ree_install() mv "${rvm_src_path}/$rvm_ruby_package_file" "${rvm_src_path}/$rvm_ruby_string" fi - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + __rvm_cd "${rvm_src_path}/$rvm_ruby_string" __rvm_setup_compile_environment "${rvm_ruby_string}" diff --git a/scripts/functions/manage/rubinius b/scripts/functions/manage/rubinius index 979a9c09c1..8a20607fb6 100644 --- a/scripts/functions/manage/rubinius +++ b/scripts/functions/manage/rubinius @@ -139,7 +139,7 @@ rubinius_install() fi fi - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" + __rvm_cd "${rvm_src_path}/$rvm_ruby_string" chmod +x ./configure diff --git a/scripts/functions/pkg b/scripts/functions/pkg index 281524229e..a7f7029646 100755 --- a/scripts/functions/pkg +++ b/scripts/functions/pkg @@ -4,7 +4,7 @@ install_package() { __rvm_db "${package}_url" "package_url" ( - chpwd_functions="" builtin cd "$rvm_src_path" + __rvm_cd "$rvm_src_path" rvm_log "Fetching $package-$version.$archive_format to $rvm_archives_path" "$rvm_scripts_path/fetch" "$package_url/$package-$version.$archive_format" || return $? @@ -21,7 +21,7 @@ install_package() ;; esac - chpwd_functions="" builtin cd "$rvm_src_path/$package-$version" + __rvm_cd "$rvm_src_path/$package-$version" __rvm_add_to_path append /usr/bin if @@ -76,7 +76,7 @@ install_package() if [[ "$action" == "uninstall" ]] then __rvm_log_command "$package/make.uninstall" "Uninstalling $package from ${prefix_path:-$rvm_usr_path}" make uninstall && - chpwd_functions="" builtin cd "$rvm_src_path" && + __rvm_cd "$rvm_src_path" && __rvm_log_command "$package/rm_src.uninstall" "Removing ${package}-${version} from $rvm_src_path" \ rm -rf "$rvm_src_path/$package-$version" && "$rvm_scripts_path/db" "$rvm_path/config/packages" "${package}" delete @@ -202,7 +202,7 @@ install_openssl() update_openssl_certs() ( - chpwd_functions="" builtin cd $rvm_usr_path/ssl && + __rvm_cd "$rvm_usr_path/ssl" && command curl -O http://curl.haxx.se/ca/cacert.pem && mv cacert.pem cert.pem ) @@ -305,12 +305,12 @@ install_llvm() package="llvm" version="89156" ( - chpwd_functions="" builtin cd $rvm_src_path + __rvm_cd $rvm_src_path if [[ ! -d "$rvm_src_path/llvm/.svn" ]] ; then __rvm_db "${package}_url" "package_url" __rvm_rm_rf "$rvm_src_path/llvm" svn co -r "$version" "$package_url" llvm - chpwd_functions="" builtin cd "$rvm_src_path/llvm" + __rvm_cd "$rvm_src_path/llvm" ./configure --enable-bindings=none UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make -j2 sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install diff --git a/scripts/functions/reset b/scripts/functions/reset index 0ad993415f..4cd3b3d42d 100644 --- a/scripts/functions/reset +++ b/scripts/functions/reset @@ -51,7 +51,7 @@ __rvm_reset() done - files=(ruby gem rake irb $(chpwd_functions="" builtin cd "${rvm_bin_path}" ; \ + files=(ruby gem rake irb $(__rvm_cd "${rvm_bin_path}" ; \ find . -mindepth 1 -maxdepth 1 -iname 'default*' -type f \ | \sed -e 's#./##g')) diff --git a/scripts/functions/rvmrc b/scripts/functions/rvmrc index c08fbc9361..83a65ca81d 100644 --- a/scripts/functions/rvmrc +++ b/scripts/functions/rvmrc @@ -161,7 +161,7 @@ __rvm_rvmrc_tools() [[ "${rvmrc_action}" == "create" ]] then rvmrc_ruby="${1:-${GEM_HOME##*/}}" - rvmrc_path="$(chpwd_functions="" builtin cd "$PWD" >/dev/null 2>&1; pwd)" + rvmrc_path="$(__rvm_cd "$PWD" >/dev/null 2>&1; pwd)" elif [[ "${1:-}" == "all" ]] then @@ -171,7 +171,7 @@ __rvm_rvmrc_tools() then rvmrc_path="${1%/.rvmrc}" else rvmrc_path="$PWD" fi - rvmrc_path="$(chpwd_functions="" builtin cd "${rvmrc_path}" >/dev/null 2>&1; pwd)" + rvmrc_path="$(__rvm_cd "${rvmrc_path}" >/dev/null 2>&1; pwd)" fi (( $# )) && shift || true diff --git a/scripts/functions/support b/scripts/functions/support index b1acfd3b90..94797ea8ae 100644 --- a/scripts/functions/support +++ b/scripts/functions/support @@ -128,6 +128,18 @@ __rvm_sed_i() fi } +# Drop in cd which _desotn't_ respect cdpath +__rvm_cd() +{ + typeset old_cdpath ret + old_cdpath="${CDPATH}" + CDPATH="." + chpwd_functions="" builtin cd "$@" + ret=$? + CDPATH="${old_cdpath}" + return $ret +} + # Drop in replacement for which compatible with OSX / ZSH __rvm_which() { diff --git a/scripts/gemsets b/scripts/gemsets index 43af858a80..4a4caf3f66 100755 --- a/scripts/gemsets +++ b/scripts/gemsets @@ -44,7 +44,7 @@ gemset_update() then rvm_log "Running gem update for all rubies and gemsets." rvm_ruby_strings="$( - chpwd_functions="" builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; + __rvm_cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print 2>/dev/null | GREP_OPTIONS="" \grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ',' )" @@ -79,7 +79,7 @@ gemset_globalcache() then rvm_log "Removing the global cache (note: this will empty the caches)" __rvm_read_lines directories < <( - chpwd_functions="" builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; + __rvm_cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print | cut -c 3- ) @@ -100,7 +100,7 @@ gemset_globalcache() rvm_log "Enabling global cache for gems." mkdir -p "$rvm_gems_cache_path" __rvm_read_lines directories < <( - chpwd_functions="" builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; + __rvm_cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print | cut -c 3- ) for directory_name in "${directories[@]//.\/}" diff --git a/scripts/help b/scripts/help index 8d1337a876..f2d1c44418 100755 --- a/scripts/help +++ b/scripts/help @@ -51,7 +51,7 @@ __rvm_help() rvm_log " Commands available with 'rvm help': - $(chpwd_functions="" builtin cd "${rvm_help_path}" ; find . -maxdepth 1 -mindepth 1 -type f -print | \tr "\n" ' ' | sed -e 's#./##g') + $(__rvm_cd "${rvm_help_path}" ; find . -maxdepth 1 -mindepth 1 -type f -print | \tr "\n" ' ' | sed -e 's#./##g') " fi diff --git a/scripts/list b/scripts/list index dca7238b7f..f0d22500a5 100755 --- a/scripts/list +++ b/scripts/list @@ -64,7 +64,7 @@ list_gemsets() printf "%b" "\nrvm gemsets\n" versions=($( - chpwd_functions="" builtin cd "${rvm_gems_path:-"$rvm_path/gems"}/" + __rvm_cd "${rvm_gems_path:-"$rvm_path/gems"}/" find . -maxdepth 1 -mindepth 1 -type d -print 2> /dev/null | \ awk '/[a-z]*-.*/ {print $NF}' | sort )) @@ -199,7 +199,7 @@ list_ruby_svn_tags() list_strings() { ( - chpwd_functions="" builtin cd "$rvm_rubies_path" + __rvm_cd "$rvm_rubies_path" find . -maxdepth 1 -mindepth 1 -type d | sed -e 's#./##g' ) @@ -214,7 +214,7 @@ list_gemset_strings() all_rubies="$(list_strings | sort)" gemsets=($( - chpwd_functions="" builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" + __rvm_cd "${rvm_gems_path:-"$rvm_path/gems"}" find . -maxdepth 1 -mindepth 1 -type d 2>/dev/null | \ xargs -n1 basename -- | \ GREP_OPTIONS="" \grep -v '^\(@\|doc$\|cache$\|system$\)' | sort @@ -264,7 +264,7 @@ list_known() list_rubies_strings() { ( - chpwd_functions="" builtin cd "$rvm_rubies_path" + __rvm_cd "$rvm_rubies_path" find -maxdepth 0 -type d | tail -n+2 | xargs -n1 basename -- | __rvm_strip ) @@ -291,7 +291,7 @@ list_rubies() printf "%b" "\nrvm rubies\n\n" rubies=($( - chpwd_functions="" builtin cd "$rvm_rubies_path/" + __rvm_cd "$rvm_rubies_path/" find . -maxdepth 1 -mindepth 1 -type d 2> /dev/null | sort )) diff --git a/scripts/migrate b/scripts/migrate index 0e021162fe..1a5d5a99d3 100755 --- a/scripts/migrate +++ b/scripts/migrate @@ -129,7 +129,7 @@ migrate_rubies() if confirm "Do you wish to move over wrappers?" then origin_wrappers_path="$rvm_wrappers_path/$expanded_source" - binaries=($(chpwd_functions="" builtin cd "${rvm_bin_path}" ; find . -maxdepth 1 -mindepth 1 -type f)) + binaries=($(__rvm_cd "${rvm_bin_path}" ; find . -maxdepth 1 -mindepth 1 -type f)) for binary_name in "${binaries[@]//.\/}" do diff --git a/scripts/repair b/scripts/repair index 47fbe6fbb5..2091c947f0 100755 --- a/scripts/repair +++ b/scripts/repair @@ -27,7 +27,7 @@ repair_gemsets() rvm_log "Removing gemsets missing names or interpreters." ( - chpwd_functions="" builtin cd "${rvm_gems_path:-"rvm_path/gems"}" + __rvm_cd "${rvm_gems_path:-"rvm_path/gems"}" directories=( $( find . -mindepth 1 -maxdepth 1 -type d | GREP_OPTIONS="" \grep '@$' ) @@ -68,7 +68,7 @@ repair_symlinks() rvm_log "Repairing symlinks..." ( - chpwd_functions="" builtin cd "${rvm_bin_path}" + __rvm_cd "${rvm_bin_path}" for executable_name in $(\find \. -type l) do @@ -96,7 +96,7 @@ repair_environments() rvm_log "Regenerating environments..." - environments=($(chpwd_functions="" builtin cd "$rvm_environments_path" ; find . -maxdepth 1 -mindepth 1 -type f)) + environments=($(__rvm_cd "$rvm_environments_path" ; find . -maxdepth 1 -mindepth 1 -type f)) for environment_name in "${environments[@]//.\/}" do @@ -122,7 +122,7 @@ repair_archives() rvm_log "Repairing archives..." - archives=($(chpwd_functions="" builtin cd "${rvm_archives_path}" ; find . -maxdepth 1 -mindepth 1 -type f)) + archives=($(__rvm_cd "${rvm_archives_path}" ; find . -maxdepth 1 -mindepth 1 -type f)) for archive_file in "${archives[@]//.\/}" do diff --git a/scripts/rubygems b/scripts/rubygems index 8c6e005012..d7b0506815 100755 --- a/scripts/rubygems +++ b/scripts/rubygems @@ -188,7 +188,7 @@ rubygems_setup() rubygems_remove # Remove old gems. - chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_gem_package_name" + __rvm_cd "${rvm_src_path}/$rvm_gem_package_name" __rvm_run "rubygems.install" \ "GEM_PATH=\"$GEM_PATH:${GEM_PATH%%@*}@global\" GEM_HOME=\"$GEM_HOME\" \"${rvm_ruby_binary}\" \"${rvm_src_path}/$rvm_gem_package_name/setup.rb\"" \ diff --git a/scripts/snapshot b/scripts/snapshot index 65b915d9ea..07dd978160 100755 --- a/scripts/snapshot +++ b/scripts/snapshot @@ -65,7 +65,7 @@ snapshot_save() mkdir -p "$snapshot_temp_path/gems" ( - chpwd_functions="" builtin cd "$snapshot_temp_path/gems" + __rvm_cd "$snapshot_temp_path/gems" for snapshot_gemset in $("$rvm_scripts_path/list" gemsets strings) ; do @@ -126,7 +126,7 @@ snapshot_save() rvm_log "Compressing snapshotting" destination_path="$PWD" ( - chpwd_functions="" builtin cd "$snapshot_temp_path" + __rvm_cd "$snapshot_temp_path" __rvm_rm_rf "$destination_path/$1.tar.gz" $rvm_tar_command czf "$destination_path/$1.tar.gz" . result="$?" @@ -167,7 +167,7 @@ snapshot_load() rvm_log "Extracting snapshot" ( - chpwd_functions="" builtin cd "$snapshot_temp_path" + __rvm_cd "$snapshot_temp_path" $rvm_tar_command xzf "$snapshot_archive" result="$?" __error_on_result "$result" "Error extracting the archive '$snapshot_archive'" && return "$result" @@ -200,7 +200,7 @@ snapshot_load() rvm_log "Setting up gemsets" ( - chpwd_functions="" builtin cd "$snapshot_temp_path/gems" + __rvm_cd "$snapshot_temp_path/gems" gems=($(find . -mindepth 0 -maxdepth 0 -type f "${name_opt}" '*.gems' | sed 's/.gems$//')) diff --git a/scripts/tools b/scripts/tools index e951d2234a..50eeff1a5a 100755 --- a/scripts/tools +++ b/scripts/tools @@ -21,7 +21,7 @@ tools_path_identifier() return 1 fi - chpwd_functions="" builtin cd "$1" + __rvm_cd "$1" __rvm_do_with_env_before rvm_promptless=1 __rvm_project_rvmrc >/dev/null 2>&1 rvmrc_result="$?"