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

Fix $PWD changes when executing Python

Specifically, this does not play well with PWD=/proc/self/cwd
This commit is contained in:
Zach Riggle
2017-11-13 15:12:13 -06:00
parent eef042ad89
commit 19e2b9588a
4 changed files with 18 additions and 13 deletions

View File

@@ -36,9 +36,10 @@ else
}
abs_dirname() {
local cwd="$PWD"
local path="$1"
# Use a subshell to avoid changing the current path
(
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
@@ -46,7 +47,7 @@ else
done
pwd
cd "$cwd"
)
}
fi
@@ -72,11 +73,13 @@ fi
if [ -z "${PYENV_DIR}" ]; then
PYENV_DIR="$PWD"
else
cd "$PYENV_DIR" 2>/dev/null || abort "cannot change working directory to \`$PYENV_DIR'"
PYENV_DIR="$PWD"
cd "$OLDPWD"
fi
if [ ! -d "$PYENV_DIR" ] || [ ! -e "$PYENV_DIR" ]; then
abort "cannot change working directory to \`$PYENV_DIR'"
fi
PYENV_DIR=$(cd "$PYENV_DIR" && echo "$PWD")
export PYENV_DIR