1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-16 15:23:53 -05:00

Fix realpath fallback in rbenv hooks

The symlinks weren't correctly resolved if they were pointing to a
single path component, such as `ln -s foo bar`.
This commit is contained in:
Mislav Marohnić
2015-10-27 20:50:14 +01:00
parent 6e02b944f7
commit 7026e529c7
2 changed files with 12 additions and 5 deletions

View File

@@ -35,16 +35,17 @@ resolve_link() {
}
realpath() {
local cwd="$(pwd)"
local cwd="$PWD"
local path="$1"
local name
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
name="${path##*/}"
[ "$name" = "$path" ] || cd "${path%/*}"
path="$(resolve_link "$name" || true)"
done
echo "$(pwd)/$name"
echo "${PWD}/$name"
cd "$cwd"
}
fi