From f31a06dc195e145367c9a928c4ef220e8e2538bf Mon Sep 17 00:00:00 2001 From: Anton Petrov Date: Mon, 22 Feb 2021 12:21:02 +0300 Subject: [PATCH] Added --nosystem argument Added --nosystem argument to skip the system environment when searching for an executable. --- libexec/pyenv-which | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libexec/pyenv-which b/libexec/pyenv-which index a7a1264a..88fc447b 100755 --- a/libexec/pyenv-which +++ b/libexec/pyenv-which @@ -2,10 +2,12 @@ # # Summary: Display the full path to an executable # -# Usage: pyenv which +# Usage: pyenv which [--nosystem] # # Displays the full path to the executable that pyenv will invoke when # you run the given command. +# Use --nosystem argument in case when you don't need to search command in the +# system environment. # set -e @@ -16,6 +18,12 @@ if [ "$1" = "--complete" ]; then exec pyenv-shims --short fi +if [ "$2" = "--nosystem" ]; then + system="" +else + system="system" +fi + remove_from_path() { local path_to_remove="$1" local path_before @@ -39,7 +47,7 @@ OLDIFS="$IFS" IFS=: versions=(${PYENV_VERSION:-$(pyenv-version-name)}) IFS="$OLDIFS" -for version in "${versions[@]}" "system"; do +for version in "${versions[@]}" "$system"; do if [ "$version" = "system" ]; then PATH="$(remove_from_path "${PYENV_ROOT}/shims")" PYENV_COMMAND_PATH="$(command -v "$PYENV_COMMAND" || true)"