From e5b2ecc125db438d4ca8ff8c198029c7abcab2c0 Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Mon, 27 Nov 2023 18:47:32 -0800 Subject: [PATCH 1/2] fix: remove non-standard tool colorize fixes #381 --- bin/pyenv-virtualenv | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index e1919d95..e6915d5e 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -488,8 +488,7 @@ if [ -z "${EZ_SETUP_URL}" ]; then fi if [ -z "${GET_PIP_URL}" ]; then if [ -n "${PIP_VERSION}" ]; then - { colorize 1 "WARNING" - echo ": Setting PIP_VERSION=${PIP_VERSION} is no longer supported and may cause failures during the install process." + { echo "WARNING: Setting PIP_VERSION=${PIP_VERSION} is no longer supported and may cause failures during the install process." } 1>&2 GET_PIP_URL="https://raw.githubusercontent.com/pypa/pip/${PIP_VERSION}/contrib/get-pip.py" # Unset `PIP_VERSION` from environment before invoking `get-pip.py` to deal with "ValueError: invalid truth value" (pypa/pip#4528) From 73f857130ead59c7cc8428a9174fec1c0642abe2 Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Tue, 28 Nov 2023 21:16:18 -0800 Subject: [PATCH 2/2] copy over colorize helper --- bin/pyenv-virtualenv | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index e6915d5e..1d355ef5 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -54,6 +54,12 @@ parse_options() { done } +colorize() { + if [ -t 1 ]; then printf "\e[%sm%s\e[m" "$1" "$2" + else echo -n "$2" + fi +} + resolve_link() { $(type -p greadlink readlink | head -1) "$1" } @@ -488,7 +494,8 @@ if [ -z "${EZ_SETUP_URL}" ]; then fi if [ -z "${GET_PIP_URL}" ]; then if [ -n "${PIP_VERSION}" ]; then - { echo "WARNING: Setting PIP_VERSION=${PIP_VERSION} is no longer supported and may cause failures during the install process." + { colorize 1 "WARNING" + echo ": Setting PIP_VERSION=${PIP_VERSION} is no longer supported and may cause failures during the install process." } 1>&2 GET_PIP_URL="https://raw.githubusercontent.com/pypa/pip/${PIP_VERSION}/contrib/get-pip.py" # Unset `PIP_VERSION` from environment before invoking `get-pip.py` to deal with "ValueError: invalid truth value" (pypa/pip#4528)