I need to pass /DEF:c:\filepath\myLib.def" command line option from a bash script to MS compiler/linker. The path is generated as part of build process by a bash script. Basically, the argument that my script passes is:
-DEF:/c/filepath/myLib.def
MSYS path conversion can't handle it properly because it doesn't understand /DEF:
part. It works if I do
-DEF=/c/filepath/myLib.def
but then ms tools don't understand this parameter. In short, what's the proper way to write that parameter in MSYS bash so that it converts it to proper argument?
On cygwin I could use cygpath, but there is no equivalent, because somebody from msys thinks that it's not needed (even if there are scripts for cygwin that uses cygpath).
use
pwd -W
or download cygpath for msys from here http://mingw.5.n7.nabble.com/enhanced-version-of-cygpath-td28556.html
and use
cygpath -wa
How about this one ?
cmd //c echo <your path>
It may not work always but it is the shortest I found
My bash foo is weak and I couldn't get regexes working in bash 3.1 so I hacked out a perl script for it:
Similar to dmitri-rubinstein@ above, I've cleaned up the code a bit and added the reverse conversion as well.
I am using this with msysgit:
Update (Aug-2016):
This question is no longer relevant, as msys2 now comes with
cygpath
in its installation....
I'll summarize my research here.
The cygpath equivalent in MSYS is to use this command:
The problem with this approach is that it requires existing path, e.g. the
c:\some\path
has to be an existing directory; however, real cygpath supports paths that do not exist.So, if you need to get path to a directory that doesn't exist, then you can fallback to sed conversion of the path:
The mouthful of slashes is there to satisfy quoting rules of
sed
. So, ifc:\some\path
doesn't exist on your PC, it will try to convert forward to back slashes and replace/c/
withc:\
(or any other drive letter). The only drawback for this is that it won't work correctly non-existing paths that contain a mounted component, such as/bin/does-not-exist
or/usr/bin/does-not-exist
.One more approach is to use cygpath from cygwin in MSYS. It seems that cygwin sets global environment variable CYGPATH, that is, you can use it from regular cmd.exe:
or from MSYS:
as long as you set to point
/c
to/cygdrive/c
in cygwin. But this approach will print you/usr
located in cygwin installation, not in MSYS.In short, I think msys should really include real cygpath in the default set of tools just for some cases that aren't handled automatically by msys command line argument conversion logic