Mingw + python eagerly translating the path

I use:

I have an environment variable that looks like an absolute path ( /path/to/dir), but I use it to create a git URL. At some point it translates to C:/Program Files/Git/path/to/dir. Python seems to be to blame:

In the git bash shell:

$ export VAR=/path/to/dir
$ echo $VAR
/path/to/dir
$ python
>>> import os
>>> os.environ['VAR']
'C:/Program Files/Git/path/to/dir'

git bash doesn't translate the path, but Python?

At the Windows command prompt, Python does this correctly:

C:\>set VAR=/path/to/dir
C:\>echo %VAR%
/path/to/dir

C:\>python
>>> import os
>>> os.environ['VAR']
'/path/to/dir'

Can anyone explain what is going on here? And how can I prevent translation in a bash shell?

EDIT: , python script OS X Windows, , - , .

+3
3

, python, git bash.
, git bash , .
/ ( ).

cygwin, :

$ export test="/bin"
$ python
>>> import os
>>> os.environ["test"]
'/bin'
+1

, MSYS. MSYS , MSYS (, msysgit bash, Windows Python), , POSIX (, , "/" ) "" Windows, , MSYS, . , .

'/' ( POSIX-), ( ), Cygwin ( MSYS). , msysgit "C:\Program Files\ Git", MSYS , "" POSIX "/path/to/dir ' .

, , . , ssh , http://comments.gmane.org/gmane.comp.gnu.mingw.msys/4511 ( 2008 ) , . , MinGW-MSYS . Gmane, , , .

+2

, msysgit, , git, POV, git python ( Python Windows , , ).

You must install Cygwin and its python package (and even the git package if you want) to get the correct POSIX environment with the binaries and libraries prepared for it.

+1
source

Source: https://habr.com/ru/post/1723518/


All Articles