mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-10-26 23:01:24 +01:00
rbenv install: fix substituting $HOME with "~" (#2501)
Depending on bash version, the expression `${var/$HOME\//~/}` will not have
effect because the "~" character in the replacement expression is expanded.
The updated approach is a bit of a mouthful, but it avoids using "~" in a
substitution pattern, while also guarding against values of HOME that are
blank or when HOME is literally just "/".
This commit is contained in:
parent
3643c8edf3
commit
fdcfac8d42
2 changed files with 9 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue