From 19c453ec8fe4407be165a6df0e60505bec7b52ed Mon Sep 17 00:00:00 2001 From: Sigmund Vik Date: Thu, 28 Oct 2021 00:47:34 +0200 Subject: [PATCH 1/2] Fix broken prompt set up by activate.bat (#2225) Removing the stray closing parenthesis in activate.bat in commit 35ec441 broke the virtual environment prompt prefix in Windows cmd. The reason for this was that the ill-formed closing parenthesis somehow affected the variable expansion order. This commit fixes the issue by not using a local ENV_PROMPT variable to update the prompt. (So an additional benefit of this change is one less variable set in the environment.) Fixes: https://github.com/pypa/virtualenv/issues/2225 --- src/virtualenv/activation/batch/activate.bat | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/virtualenv/activation/batch/activate.bat b/src/virtualenv/activation/batch/activate.bat index 2ce9e5ac8..184e4f9e1 100644 --- a/src/virtualenv/activation/batch/activate.bat +++ b/src/virtualenv/activation/batch/activate.bat @@ -13,11 +13,11 @@ if defined _OLD_VIRTUAL_PROMPT ( ) ) if not defined VIRTUAL_ENV_DISABLE_PROMPT ( - set "ENV_PROMPT=__VIRTUAL_PROMPT__" - if NOT DEFINED ENV_PROMPT ( - for %%d in ("%VIRTUAL_ENV%") do set "ENV_PROMPT=(%%~nxd) " + if "__VIRTUAL_PROMPT__" NEQ "" ( + set "PROMPT=__VIRTUAL_PROMPT__%PROMPT%" + ) else ( + for %%d in ("%VIRTUAL_ENV%") do set "PROMPT=(%%~nxd) %PROMPT%" ) - set "PROMPT=%ENV_PROMPT%%PROMPT%" ) REM Don't use () to avoid problems with them in %PATH% From a47e7bf893d0a18559d295a789df423d2bbda0a9 Mon Sep 17 00:00:00 2001 From: Sigmund Vik Date: Thu, 28 Oct 2021 00:52:27 +0200 Subject: [PATCH 2/2] Add changelog entry --- docs/changelog/2225.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changelog/2225.bugfix.rst diff --git a/docs/changelog/2225.bugfix.rst b/docs/changelog/2225.bugfix.rst new file mode 100644 index 000000000..f7cab3e55 --- /dev/null +++ b/docs/changelog/2225.bugfix.rst @@ -0,0 +1 @@ +Fix broken prompt set up by activate.bat - by :user:`SiggyBar`.