Merge pull request #1133 from pyenv/rbenv-20180402

Import changes from rbenv as of 20180402
This commit is contained in:
Yamashita, Yuu 2018-04-05 16:47:20 +09:00 committed by GitHub
commit 35f7ef8708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 57 additions and 34 deletions

View file

@ -1,6 +1,5 @@
#!/usr/bin/env bash
set -e
unset CDPATH
if [ "$1" = "--debug" ]; then
export PYENV_DEBUG=1
@ -22,7 +21,8 @@ abort() {
if enable -f "${BASH_SOURCE%/*}"/../libexec/pyenv-realpath.dylib realpath 2>/dev/null; then
abs_dirname() {
local path="$(realpath "$1")"
local path
path="$(realpath "$1")"
echo "${path%/*}"
}
else
@ -69,6 +69,11 @@ if [ -z "${PYENV_DIR}" ]; then
export PYENV_DIR
unset PYENV_FILE_ARG
fi
else
[[ $PYENV_DIR == /* ]] || PYENV_DIR="$PWD/$PYENV_DIR"
cd "$PYENV_DIR" 2>/dev/null || abort "cannot change working directory to \`$PYENV_DIR'"
PYENV_DIR="$PWD"
cd "$OLDPWD"
fi
if [ -z "${PYENV_DIR}" ]; then
@ -121,7 +126,13 @@ case "$command" in
;;
* )
command_path="$(command -v "pyenv-$command" || true)"
[ -n "$command_path" ] || abort "no such command \`$command'"
if [ -z "$command_path" ]; then
if [ "$command" == "shell" ]; then
abort "shell integration not enabled. Run \`pyenv init' for instructions."
else
abort "no such command \`$command'"
fi
fi
shift 1
if [ "$1" = --help ]; then

View file

@ -28,15 +28,15 @@ shopt -s nullglob
for command in "${path}/pyenv-"*; do
command="${command##*pyenv-}"
if [ -n "$sh" ]; then
if [ ${command:0:3} = "sh-" ]; then
echo ${command##sh-}
if [ "${command:0:3}" = "sh-" ]; then
echo "${command##sh-}"
fi
elif [ -n "$nosh" ]; then
if [ ${command:0:3} != "sh-" ]; then
echo ${command##sh-}
if [ "${command:0:3}" != "sh-" ]; then
echo "${command##sh-}"
fi
else
echo ${command##sh-}
echo "${command##sh-}"
fi
done
done

View file

@ -42,6 +42,7 @@ extract_initial_comment_block() {
}
collect_documentation() {
# shellcheck disable=SC2016
$(type -p gawk awk | head -1) '
/^Summary:/ {
summary = substr($0, 10)
@ -86,7 +87,8 @@ collect_documentation() {
}
documentation_for() {
local filename="$(command_path "$1")"
local filename
filename="$(command_path "$1")"
if [ -n "$filename" ]; then
extract_initial_comment_block < "$filename" | collect_documentation
fi
@ -114,7 +116,7 @@ print_help() {
eval "$(documentation_for "$command")"
[ -n "$help" ] || help="$summary"
if [ -n "$usage" -o -n "$summary" ]; then
if [ -n "$usage" ] || [ -n "$summary" ]; then
if [ -n "$usage" ]; then
echo "$usage"
else

View file

@ -138,7 +138,7 @@ esac
if [ "$shell" != "fish" ]; then
IFS="|"
cat <<EOS
command="\$1"
command="\${1:-}"
if [ "\$#" -gt 0 ]; then
shift
fi

View file

@ -16,7 +16,7 @@ mkdir -p "$SHIM_PATH"
# to stderr and exit with a non-zero status.
set -o noclobber
{ echo > "$PROTOTYPE_SHIM_PATH"
} 2>/dev/null ||
} 2>| /dev/null ||
{ if [ -w "$SHIM_PATH" ]; then
echo "pyenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists"
else
@ -83,7 +83,7 @@ remove_outdated_shims() {
list_executable_names() {
local version file
pyenv-versions --bare --skip-aliases | \
while read version; do
while read -r version; do
for file in "${PYENV_ROOT}/versions/${version}/bin/"*; do
echo "${file##*/}"
done
@ -136,6 +136,7 @@ shopt -s nullglob
# executables.
create_prototype_shim
remove_outdated_shims
# shellcheck disable=SC2046
make_shims $(list_executable_names | sort -u)

View file

@ -1,3 +1,3 @@
#!/usr/bin/env bash
# Summary: Display the root directory where versions and shims are kept
echo $PYENV_ROOT
echo "$PYENV_ROOT"

View file

@ -20,7 +20,7 @@ fi
whence() {
local command="$1"
pyenv-versions --bare | while read version; do
pyenv-versions --bare | while read -r version; do
path="$(pyenv-prefix "$version")/bin/${command}"
if [ -x "$path" ]; then
[ "$print_paths" ] && echo "$path" || echo "$version"

24
src/configure vendored
View file

@ -34,16 +34,16 @@ esac
eval "$("$src_dir"/shobj-conf -C "$CC" -o "$host_os")"
sed "
s,@CC@,${CC},
s,@CFLAGS@,${CFLAGS},
s,@LOCAL_CFLAGS@,${LOCAL_CFLAGS},
s,@DEFS@,${DEFS},
s,@LOCAL_DEFS@,${LOCAL_DEFS},
s,@SHOBJ_CC@,${SHOBJ_CC},
s,@SHOBJ_CFLAGS@,${SHOBJ_CFLAGS},
s,@SHOBJ_LD@,${SHOBJ_LD},
s,@SHOBJ_LDFLAGS@,${SHOBJ_LDFLAGS//,/\\,},
s,@SHOBJ_XLDFLAGS@,${SHOBJ_XLDFLAGS//,/\\,},
s,@SHOBJ_LIBS@,${SHOBJ_LIBS},
s,@SHOBJ_STATUS@,${SHOBJ_STATUS},
s#@CC@#${CC}#
s#@CFLAGS@#${CFLAGS}#
s#@LOCAL_CFLAGS@#${LOCAL_CFLAGS}#
s#@DEFS@#${DEFS}#
s#@LOCAL_DEFS@#${LOCAL_DEFS}#
s#@SHOBJ_CC@#${SHOBJ_CC}#
s#@SHOBJ_CFLAGS@#${SHOBJ_CFLAGS}#
s#@SHOBJ_LD@#${SHOBJ_LD}#
s#@SHOBJ_LDFLAGS@#${SHOBJ_LDFLAGS}#
s#@SHOBJ_XLDFLAGS@#${SHOBJ_XLDFLAGS}#
s#@SHOBJ_LIBS@#${SHOBJ_LIBS}#
s#@SHOBJ_STATUS@#${SHOBJ_STATUS}#
" "$src_dir"/Makefile.in > "$src_dir"/Makefile

View file

@ -2,6 +2,17 @@
load test_helper
@test "shell integration disabled" {
run pyenv shell
assert_failure "pyenv: shell integration not enabled. Run \`pyenv init' for instructions."
}
@test "shell integration enabled" {
eval "$(pyenv init -)"
run pyenv shell
assert_success "pyenv: no shell-specific version configured"
}
@test "no shell version" {
mkdir -p "${PYENV_TEST_DIR}/myproject"
cd "${PYENV_TEST_DIR}/myproject"

View file

@ -9,7 +9,7 @@ setup() {
create_file() {
mkdir -p "$(dirname "$1")"
touch "$1"
echo "system" > "$1"
}
@test "detects global 'version' file" {

View file

@ -26,7 +26,7 @@ setup() {
}
@test "detects local file" {
touch .python-version
echo "system" > .python-version
run pyenv-version-origin
assert_success "${PWD}/.python-version"
}

View file

@ -60,12 +60,11 @@ create_executable() {
}
@test "doesn't include current directory in PATH search" {
export PATH="$(path_without "kill-all-humans")"
mkdir -p "$PYENV_TEST_DIR"
cd "$PYENV_TEST_DIR"
touch kill-all-humans
chmod +x kill-all-humans
PYENV_VERSION=system run pyenv-which kill-all-humans
PATH="$(path_without "kill-all-humans")" PYENV_VERSION=system run pyenv-which kill-all-humans
assert_failure "pyenv: kill-all-humans: command not found"
}
@ -91,9 +90,8 @@ OUT
}
@test "no executable found for system version" {
export PATH="$(path_without "py.test")"
PYENV_VERSION=system run pyenv-which py.test
assert_failure "pyenv: py.test: command not found"
PATH="$(path_without "rake")" PYENV_VERSION=system run pyenv-which rake
assert_failure "pyenv: rake: command not found"
}
@test "executable found in other versions" {