cygpath -w converts relative paths to absolute windows paths

Corinna Vinschen corinna-cygwin@cygwin.com
Sun Feb 12 11:23:00 GMT 2017


On Feb  7 14:35, Roger Qiu wrote:
> Hi,
> 
> I've found that `cygpath --windows '../` will give back an absolute windows
> path.
> 
> I thought this would only happen if you provide the `--absolute` flag, or
> when the path is a special cygwin path.
> 
> But this occurs just for normal directories.
> 
> I have come across a situation where I need to convert ntfs symlinks to unix
> symlinks and back. Sometimes these symlinks have relative paths them. Now by
> using cygpath --windows, I get back absolute paths, which means the
> integrity of the symlink isn't preserved.
> 
> Can `cygpath --windows '../directory'` give back `..\directory` for paths
> aren't special cygwin paths? These relative backslashes are supported in
> Windows right now.

Not easily.  All paths are evaluated as absolute paths inside Cygwin.
The result of the path conversion is always an absolute path. A relative
path is generated from there by checking if the path prefix in POSIX
notation is identical to the current working directory.  If not, the
path stays absolute.  Naturally, if you use a "..", the resulting path
does not match the CWD anymore, so you're out.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20170212/16f49f8b/attachment.sig>


More information about the Cygwin mailing list