Skip to content

Commit

Permalink
Stub out cd with __rvm_cd
Browse files Browse the repository at this point in the history
Leaves CDPATH alone except when actually switching directories

Also fix some unquoted paths
  • Loading branch information
richo committed Dec 13, 2012
1 parent 4dd7772 commit b78b823
Show file tree
Hide file tree
Showing 29 changed files with 90 additions and 78 deletions.
2 changes: 1 addition & 1 deletion binscripts/rvm-installer
Expand Up @@ -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"

This comment has been minimized.

Copy link
@rhasti

rhasti Dec 15, 2012

This patch causes installer not to work on CentOS 6.3 minimal as well on Fedora 18.

See https://gist.github.com/4294194

Function __rvm_cd not defined in file binscripts/rvm-installer

This comment has been minimized.

Copy link
@mpapis

mpapis Dec 15, 2012

Member

fixed with #1390

if ! __rvm_cd "${rvm_src_path}/rvm"
then
log "Could not change directory '${rvm_src_path}/rvm'."
return 2
Expand Down
4 changes: 2 additions & 2 deletions scripts/alias
Expand Up @@ -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#.*/##'
)
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/cli
Expand Up @@ -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[@]}"
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/disk-usage
Expand Up @@ -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
)
;;
Expand Down
4 changes: 2 additions & 2 deletions scripts/docs
Expand Up @@ -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..."

Expand All @@ -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/"

Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/functions/cleanup
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions scripts/functions/installer
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
))

Expand Down
32 changes: 16 additions & 16 deletions scripts/functions/manage/base
Expand Up @@ -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=( "$@" ) ;;
Expand Down Expand Up @@ -71,7 +71,7 @@ __rvm_apply_patches()
result=1
fi
done
chpwd_functions="" builtin cd "${_save_dir}"
__rvm_cd "${_save_dir}"
return ${result:-0}
}

Expand Down Expand Up @@ -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
Expand All @@ -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=$?
Expand Down Expand Up @@ -410,15 +410,15 @@ __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}"
)
elif
[[ -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
Expand Down Expand Up @@ -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
Expand All @@ -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}"
Expand All @@ -477,15 +477,15 @@ __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
fi

(
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$/")" ]]
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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[*]} )) ||
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/functions/manage/goruby
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/functions/manage/ironruby
Expand Up @@ -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)"

Expand Down
10 changes: 5 additions & 5 deletions scripts/functions/manage/jruby
Expand Up @@ -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
Expand Down Expand Up @@ -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} ))
Expand Down Expand Up @@ -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}"
Expand All @@ -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}"
Expand Down
12 changes: 6 additions & 6 deletions scripts/functions/manage/maglev
Expand Up @@ -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)"
Expand All @@ -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}"

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/functions/manage/mruby
Expand Up @@ -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
Expand All @@ -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=$?
Expand Down

0 comments on commit b78b823

Please sign in to comment.