Cygpath cannot convert Windows path to Linux path

I am trying to convert file paths to / from Linux and Windows on a Windows Machine.

the unix path to windows works fine.

$ cygpath -w /cygdrive/c/CYGWIN/CYGBuild/build.mak C:\CYGWIN\CYGBuild\build.mak 

But the Windows path to Linux gives the wrong conclusion. ie Missing '/' as well as cygdrive

 $ cygpath -uc:\cygwin\cygbuild\build.mak c:cygwincygbuildbuild.mak 

Has anyone encountered this issue? Share your experience.

thanks

+4
source share
3 answers

I got an answer to this question.

 $ cygpath -u 'c:\cygwin\cygbuild\build.mak' 

i.e. the path must be in a single quote.

+9
source

Actually, as far as I know; you need slashes in the paths used by cygwin. Single quotes help in cases where there are spaces in the path (and my guess is in this case, using a backslash instead of straight forward slashes). Otherwise, backslashes are like escape characters , while spaces (although not in your case) require escape characters themselves. Thus, quoting a path tends to eliminate such a nuisance.

Here are the links that help me figure this out:

  • This is an opencv (using cygwin) tutorial, page 4, where there is an example of the paths used, with and without quotes, indicating when you can need them.
  • It is also very useful; a list of Cygwin's frequently asked questions, including how to deal with spaces (or in this case, backslashes in the path where quotes will be added).
+2
source

The cygpath -m option is probably the easiest solution. Windows software usually accepts / as well as \ . (There may be a few exceptions, but the development tools I'm working with are fine with him.)

 $ cygpath -m /cygdrive/c/CYGWIN/CYGBuild/build.mak C:/Cygwin/CYGBuild/build.mak 
0
source

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


All Articles