Skip to content

Commit

Permalink
Do not turn echo off for subsequent commands in batch activators (#2411
Browse files Browse the repository at this point in the history
…) (#2412)

Co-authored-by: Paweł Szramowski <[email protected]>
  • Loading branch information
pawelszramowski and Paweł Szramowski authored Sep 8, 2022
1 parent d9575ee commit dbedec5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 37 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/2411.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Do not turn echo off for subsequent commands in batch activators
(``activate.bat`` and ``deactivate.bat``) - by :user:`pawelszramowski`.
46 changes: 22 additions & 24 deletions src/virtualenv/activation/batch/activate.bat
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
@echo off
@set "VIRTUAL_ENV=__VIRTUAL_ENV__"

set "VIRTUAL_ENV=__VIRTUAL_ENV__"

if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
@if defined _OLD_VIRTUAL_PROMPT (
@set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
) else (
if not defined PROMPT (
set "PROMPT=$P$G"
@if not defined PROMPT (
@set "PROMPT=$P$G"
)
if not defined VIRTUAL_ENV_DISABLE_PROMPT (
set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
@if not defined VIRTUAL_ENV_DISABLE_PROMPT (
@set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
)
)
if not defined VIRTUAL_ENV_DISABLE_PROMPT (
if "__VIRTUAL_PROMPT__" NEQ "" (
set "PROMPT=(__VIRTUAL_PROMPT__) %PROMPT%"
@if not defined VIRTUAL_ENV_DISABLE_PROMPT (
@if "__VIRTUAL_PROMPT__" NEQ "" (
@set "PROMPT=(__VIRTUAL_PROMPT__) %PROMPT%"
) else (
for %%d in ("%VIRTUAL_ENV%") do set "PROMPT=(%%~nxd) %PROMPT%"
@for %%d in ("%VIRTUAL_ENV%") do @set "PROMPT=(%%~nxd) %PROMPT%"
)
)

REM Don't use () to avoid problems with them in %PATH%
if defined _OLD_VIRTUAL_PYTHONHOME goto ENDIFVHOME
set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
@REM Don't use () to avoid problems with them in %PATH%
@if defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
@set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
:ENDIFVHOME

set PYTHONHOME=
@set PYTHONHOME=

REM if defined _OLD_VIRTUAL_PATH (
if not defined _OLD_VIRTUAL_PATH goto ENDIFVPATH1
set "PATH=%_OLD_VIRTUAL_PATH%"
@REM if defined _OLD_VIRTUAL_PATH (
@if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH1
@set "PATH=%_OLD_VIRTUAL_PATH%"
:ENDIFVPATH1
REM ) else (
if defined _OLD_VIRTUAL_PATH goto ENDIFVPATH2
set "_OLD_VIRTUAL_PATH=%PATH%"
@REM ) else (
@if defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH2
@set "_OLD_VIRTUAL_PATH=%PATH%"
:ENDIFVPATH2

set "PATH=%VIRTUAL_ENV%\__BIN_NAME__;%PATH%"
@set "PATH=%VIRTUAL_ENV%\__BIN_NAME__;%PATH%"
24 changes: 11 additions & 13 deletions src/virtualenv/activation/batch/deactivate.bat
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
@echo off
@set VIRTUAL_ENV=

set VIRTUAL_ENV=

REM Don't use () to avoid problems with them in %PATH%
if not defined _OLD_VIRTUAL_PROMPT goto ENDIFVPROMPT
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
set _OLD_VIRTUAL_PROMPT=
@REM Don't use () to avoid problems with them in %PATH%
@if not defined _OLD_VIRTUAL_PROMPT @goto ENDIFVPROMPT
@set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
@set _OLD_VIRTUAL_PROMPT=
:ENDIFVPROMPT

if not defined _OLD_VIRTUAL_PYTHONHOME goto ENDIFVHOME
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
set _OLD_VIRTUAL_PYTHONHOME=
@if not defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
@set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
@set _OLD_VIRTUAL_PYTHONHOME=
:ENDIFVHOME

if not defined _OLD_VIRTUAL_PATH goto ENDIFVPATH
set "PATH=%_OLD_VIRTUAL_PATH%"
set _OLD_VIRTUAL_PATH=
@if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH
@set "PATH=%_OLD_VIRTUAL_PATH%"
@set _OLD_VIRTUAL_PATH=
:ENDIFVPATH

0 comments on commit dbedec5

Please sign in to comment.