14

I am using Git bash in windows to run a .sh shell script. This script takes some arguments. One of those arguments is a path as shown below:

Test test --path /ROOT/phani123 --comment testing

When I debug the path argument through my Javacode it actually looks like C:/Program Files/Git/ROOT/phani123. Git bash is prepending its location to the path I've passed.

How to stop Git bash doing this?

dimo414
  • 47,227
  • 18
  • 148
  • 244
Phani
  • 481
  • 1
  • 4
  • 9
  • 2
    Phani, any luck? i have the same issue – srini Jun 16 '17 at 17:31
  • No.. may be it is how Git bash behaves in windows. – Phani Jun 27 '17 at 07:41
  • See here for possible solutions: https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line#34386471 – John Apr 17 '18 at 15:44
  • 1
    Does this answer your question? [How to stop MinGW and MSYS from mangling path names given at the command line](https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line) – daveloyall Nov 13 '19 at 22:03
  • The solution John proposes will likely work if you are using a recent version of git-bash, Phani. (I recommend the latest version, 2.24.0 as of 2019-11-13). So, I've flagged this question as a duplicate of that one. – daveloyall Nov 13 '19 at 22:04
  • @John It doesn't work any longer. And in my case the alternative solution of double-slash at the beginning is changing the value of an ID that starts with a forward slash. Obviously it cannot be found. – Berin Loritsch Dec 08 '22 at 19:25

2 Answers2

2

You need to set the following environment variable to disable this:

export MSYS_NO_PATHCONV=1

See https://stackoverflow.com/a/34386471/8261

Rich
  • 15,048
  • 2
  • 66
  • 119
  • Bizarre that this question only got properly answered 7 years after being asked??? At least, it worked for me just now... – spechter Apr 20 '23 at 23:40
0

Shamelessly copied from the other thread with an MSYS focus, for clarity here: (Go and give the answer a +1)

In summary, to disable this Posix path convesion:

spechter
  • 2,058
  • 1
  • 17
  • 23