Passing a path from Bash to Python on Windows automatically tries to convert it to an absolute path - is there a way to prohibit that?

Viewed 183

I am trying to pass a path to a Python script as an argument using sys.argv[x]. However the passing of said path from Bash to Python seems to convert it to a different path. Why is that? Code:

#!/bin/sh
path='/var/log'
echo "$path"
python script.py "$path"

#!/usr/bin/env python3
import sys
logPath = sys.argv[1]
print(logPath)

Output:

/var/log/
C:/Program Files/Git/var/log/
1 Answers

Ok, I did some further investigation and found out that this is a known "feature" of mingw trying to be smart. To fix it I added the following export to my bash script:

export MSYS_NO_PATHCONV=1

You can read more about this on git:

https://github.com/moby/moby/issues/24029

Related