Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbenv install: fix substituting $HOME with "~" #2501

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bin/rbenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ if [ "$STATUS" == "2" ]; then
printf ":\n\n"
echo " brew upgrade ruby-build"
elif [ -d "${here}/.git" ]; then
display_here="$here"
[[ -z "${HOME%/}" || $here != "${HOME}/"* ]] || display_here="~${here#"$HOME"}"
printf ":\n\n"
echo " git -C ${here/${HOME}\//~/} pull"
echo " git -C $display_here pull"
else
printf ".\n"
fi
Expand Down
7 changes: 6 additions & 1 deletion test/rbenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ OUT
}

@test "nonexistent version" {
display_here="${BATS_TEST_DIRNAME}"/..
if [[ -n $HOME && $display_here == "${HOME}/"* ]]; then
display_here="~${display_here#"${HOME}"}"
fi

stub_git_dir=
if [ ! -d "${BATS_TEST_DIRNAME}"/../.git ]; then
stub_git_dir="${BATS_TEST_DIRNAME}"/../.git
Expand All @@ -113,7 +118,7 @@ See all available versions with \`rbenv install --list-all'.

If the version you need is missing, try upgrading ruby-build:

git -C ${BATS_TEST_DIRNAME/$HOME\//~/}/.. pull
git -C $display_here pull
OUT

unstub brew
Expand Down
Loading