diff options
author | James Morris <6653392+J-M0@users.noreply.github.com> | 2023-12-11 17:27:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 17:27:15 (GMT) |
commit | d7b5f102319bb0389c5248e9ecf533eae4163424 (patch) | |
tree | 79722f4d33c3fcbe665be1805e8010060f39d698 /Lib/venv/scripts | |
parent | f4fe65e2dd7eda33c098c8af3a1974c5f7f11ab7 (diff) | |
download | cpython-d7b5f102319bb0389c5248e9ecf533eae4163424.zip cpython-d7b5f102319bb0389c5248e9ecf533eae4163424.tar.gz cpython-d7b5f102319bb0389c5248e9ecf533eae4163424.tar.bz2 |
gh-112507: Detect Cygwin and MSYS with `uname` instead of `$OSTYPE` (GH-112508)
Detect Cygwin and MSYS with `uname` instead of `$OSTYPE`
`$OSTYPE` is not defined by POSIX and may not be present in other shells.
`uname` is always available in any shell.
Diffstat (limited to 'Lib/venv/scripts')
-rw-r--r-- | Lib/venv/scripts/common/activate | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Lib/venv/scripts/common/activate b/Lib/venv/scripts/common/activate index 6fdf423..a4e0609 100644 --- a/Lib/venv/scripts/common/activate +++ b/Lib/venv/scripts/common/activate @@ -36,14 +36,18 @@ deactivate () { deactivate nondestructive # 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 +case "$(uname)" in + CYGWIN*|MSYS*) + # transform D:\path\to\venv to /d/path/to/venv on MSYS + # and to /cygdrive/d/path/to/venv on Cygwin + VIRTUAL_ENV=$(cygpath "__VENV_DIR__") + export VIRTUAL_ENV + ;; + *) + # use the path as-is + export VIRTUAL_ENV="__VENV_DIR__" + ;; +esac _OLD_VIRTUAL_PATH="$PATH" PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH" |