Demetri Demetri - 6 months ago 20
Bash Question

How do I pass an arbitrary command line argument to a native Windows program from a MinGW shell?

How do I pass an arbitrary command line argument to a native Windows program from a MinGW shell?

I would like a general solution, but a solution that works for any valid Windows filename would be acceptable.

Answer

That shell is Bash. Cygwin/MSYS2 Bash can accept Windows paths, but they need to either be quoted:

program 'C:\alfa\bravo.txt'

or forward slashes:

program C:/alfa/bravo.txt

As you can see, if you are supplying Windows paths, this is pretty straight forward. The only issue you might get is if you are trying to supply Bash paths to a Windows native program:

program /tmp/bravo.txt

Windows native programs have no concept of /tmp or even /. Cygwin/MSYS2 have cygpath to assist in converting these paths:

program "$(cygpath /tmp/bravo.txt)"

Side note: MinGW is an old project. You should be using Cygwin or MSYS2.

Comments