Skip to content

Commit

Permalink
Fix broken prompt set up by activate.bat (pypa#2225)
Browse files Browse the repository at this point in the history
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: pypa#2225
  • Loading branch information
SigmundVik committed Oct 27, 2021
1 parent 653d4eb commit 19c453e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/virtualenv/activation/batch/activate.bat
Expand Up @@ -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%
Expand Down

0 comments on commit 19c453e

Please sign in to comment.