Skip to content

Commit d7b5f10

Browse files
authored
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.
1 parent f4fe65e commit d7b5f10

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Lib/venv/scripts/common/activate

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ deactivate () {
3636
deactivate nondestructive
3737

3838
# on Windows, a path can contain colons and backslashes and has to be converted:
39-
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
40-
# transform D:\path\to\venv to /d/path/to/venv on MSYS
41-
# and to /cygdrive/d/path/to/venv on Cygwin
42-
export VIRTUAL_ENV=$(cygpath "__VENV_DIR__")
43-
else
44-
# use the path as-is
45-
export VIRTUAL_ENV="__VENV_DIR__"
46-
fi
39+
case "$(uname)" in
40+
CYGWIN*|MSYS*)
41+
# transform D:\path\to\venv to /d/path/to/venv on MSYS
42+
# and to /cygdrive/d/path/to/venv on Cygwin
43+
VIRTUAL_ENV=$(cygpath "__VENV_DIR__")
44+
export VIRTUAL_ENV
45+
;;
46+
*)
47+
# use the path as-is
48+
export VIRTUAL_ENV="__VENV_DIR__"
49+
;;
50+
esac
4751

4852
_OLD_VIRTUAL_PATH="$PATH"
4953
PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"

0 commit comments

Comments
 (0)