summaryrefslogtreecommitdiffstats
path: root/Lib/venv
diff options
context:
space:
mode:
authorStanislav Syekirin <syekirin@gmail.com>2023-04-11 19:20:46 (GMT)
committerGitHub <noreply@github.com>2023-04-11 19:20:46 (GMT)
commitebc81034278ea186b4110c7dbf6d1c2a0ada9398 (patch)
treee1e31650c1ea745f5037f9f3b912ce48cfefc7ba /Lib/venv
parentb57105ae33e1f61e6bdf0eec45c4135d067b9b22 (diff)
downloadcpython-ebc81034278ea186b4110c7dbf6d1c2a0ada9398.zip
cpython-ebc81034278ea186b4110c7dbf6d1c2a0ada9398.tar.gz
cpython-ebc81034278ea186b4110c7dbf6d1c2a0ada9398.tar.bz2
gh-103088: Sanitize venv paths when using MSYS or Cygwin Bash (GH-103325)
Diffstat (limited to 'Lib/venv')
-rw-r--r--Lib/venv/scripts/common/activate11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/venv/scripts/common/activate b/Lib/venv/scripts/common/activate
index 6fbc2b8..cb898b3 100644
--- a/Lib/venv/scripts/common/activate
+++ b/Lib/venv/scripts/common/activate
@@ -38,8 +38,15 @@ deactivate () {
# unset irrelevant variables
deactivate nondestructive
-VIRTUAL_ENV="__VENV_DIR__"
-export VIRTUAL_ENV
+# on Windows, a path can contain colons and backslashes and has to be converted:
+if [ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ] ; then
+ # transform D:\path\to\venv to /d/path/to/venv on MSYS
+ # and to /cygdrive/d/path/to/venv on Cygwin
+ export VIRTUAL_ENV=$(cygpath "__VENV_DIR__")
+else
+ # use the path as-is
+ export VIRTUAL_ENV="__VENV_DIR__"
+fi
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"