Skip to content

Commit 904b6e8

Browse files
committed
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 fb202af commit 904b6e8

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
@@ -39,14 +39,18 @@ deactivate () {
3939
deactivate nondestructive
4040

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

5155
_OLD_VIRTUAL_PATH="$PATH"
5256
PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"

0 commit comments

Comments
 (0)