mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Fix $PWD changes when executing Python
Specifically, this does not play well with PWD=/proc/self/cwd
This commit is contained in:
parent
eef042ad89
commit
19e2b9588a
4 changed files with 18 additions and 13 deletions
|
@ -36,9 +36,10 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
abs_dirname() {
|
abs_dirname() {
|
||||||
local cwd="$PWD"
|
|
||||||
local path="$1"
|
local path="$1"
|
||||||
|
|
||||||
|
# Use a subshell to avoid changing the current path
|
||||||
|
(
|
||||||
while [ -n "$path" ]; do
|
while [ -n "$path" ]; do
|
||||||
cd "${path%/*}"
|
cd "${path%/*}"
|
||||||
local name="${path##*/}"
|
local name="${path##*/}"
|
||||||
|
@ -46,7 +47,7 @@ else
|
||||||
done
|
done
|
||||||
|
|
||||||
pwd
|
pwd
|
||||||
cd "$cwd"
|
)
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -72,11 +73,13 @@ fi
|
||||||
|
|
||||||
if [ -z "${PYENV_DIR}" ]; then
|
if [ -z "${PYENV_DIR}" ]; then
|
||||||
PYENV_DIR="$PWD"
|
PYENV_DIR="$PWD"
|
||||||
else
|
|
||||||
cd "$PYENV_DIR" 2>/dev/null || abort "cannot change working directory to \`$PYENV_DIR'"
|
|
||||||
PYENV_DIR="$PWD"
|
|
||||||
cd "$OLDPWD"
|
|
||||||
fi
|
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
|
export PYENV_DIR
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,10 @@ resolve_link() {
|
||||||
}
|
}
|
||||||
|
|
||||||
realpath() {
|
realpath() {
|
||||||
local cwd="$PWD"
|
|
||||||
local path="$1"
|
local path="$1"
|
||||||
local name
|
local name
|
||||||
|
# Use a subshell to avoid changing the current path
|
||||||
|
(
|
||||||
while [ -n "$path" ]; do
|
while [ -n "$path" ]; do
|
||||||
name="${path##*/}"
|
name="${path##*/}"
|
||||||
[ "$name" = "$path" ] || cd "${path%/*}"
|
[ "$name" = "$path" ] || cd "${path%/*}"
|
||||||
|
@ -48,7 +48,7 @@ realpath() {
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "${PWD}/$name"
|
echo "${PWD}/$name"
|
||||||
cd "$cwd"
|
)
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,11 @@ if ! enable -f "${BASH_SOURCE%/*}"/pyenv-realpath.dylib realpath 2>/dev/null; th
|
||||||
}
|
}
|
||||||
|
|
||||||
realpath() {
|
realpath() {
|
||||||
local cwd="$PWD"
|
|
||||||
local path="$1"
|
local path="$1"
|
||||||
local name
|
local name
|
||||||
|
|
||||||
|
# Use a subshell to avoid changing the current path
|
||||||
|
(
|
||||||
while [ -n "$path" ]; do
|
while [ -n "$path" ]; do
|
||||||
name="${path##*/}"
|
name="${path##*/}"
|
||||||
[ "$name" = "$path" ] || cd "${path%/*}"
|
[ "$name" = "$path" ] || cd "${path%/*}"
|
||||||
|
@ -55,7 +56,7 @@ if ! enable -f "${BASH_SOURCE%/*}"/pyenv-realpath.dylib realpath 2>/dev/null; th
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "${PWD}/$name"
|
echo "${PWD}/$name"
|
||||||
cd "$cwd"
|
)
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,10 @@ resolve_link() {
|
||||||
}
|
}
|
||||||
|
|
||||||
abs_dirname() {
|
abs_dirname() {
|
||||||
local cwd="$(pwd)"
|
|
||||||
local path="$1"
|
local path="$1"
|
||||||
|
|
||||||
|
# Use a subshell to avoid modifying the current path
|
||||||
|
(
|
||||||
while [ -n "$path" ]; do
|
while [ -n "$path" ]; do
|
||||||
cd "${path%/*}"
|
cd "${path%/*}"
|
||||||
local name="${path##*/}"
|
local name="${path##*/}"
|
||||||
|
@ -70,7 +71,7 @@ abs_dirname() {
|
||||||
done
|
done
|
||||||
|
|
||||||
pwd
|
pwd
|
||||||
cd "$cwd"
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
capitalize() {
|
capitalize() {
|
||||||
|
|
Loading…
Reference in a new issue