Re: cygpath -w converts relative paths to absolute windows paths

2017-02-13 Thread Thomas Wolff

Am 13.02.2017 um 16:16 schrieb Corinna Vinschen:

On Feb 12 18:38, Thomas Wolff wrote:

Am 12.02.2017 um 12:23 schrieb Corinna Vinschen:

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.

How about converting getcwd(), too, and comparing that?

Converting to what?  And how's that different from what I describe above?
I was looking at path.cc, function mkrelpath, and (without tracing 
anything) assumed this would be the relevant function and had the 
impression that, when comparing path_prefix_p (cwd_win32, path, ...), 
path might be "normalized" (resolving links and folding ".." components) 
while cwd_win32 might not. If that's the case, it might be sufficient to 
"normalize" cwd_win32 as well.



Btw., did you see https://cygwin.com/ml/cygwin/2017-01/msg00404.html?

No, I hadn't, sorry. Will respond there.
--
Thomas

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-13 Thread Corinna Vinschen
On Feb 12 18:38, Thomas Wolff wrote:
> Am 12.02.2017 um 12:23 schrieb Corinna Vinschen:
> > 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.
> How about converting getcwd(), too, and comparing that?

Converting to what?  And how's that different from what I describe above?

Btw., did you see https://cygwin.com/ml/cygwin/2017-01/msg00404.html?


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


Re: cygpath -w converts relative paths to absolute windows paths

2017-02-12 Thread Thomas Wolff

Am 12.02.2017 um 12:23 schrieb Corinna Vinschen:

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.

How about converting getcwd(), too, and comparing that?
--
Thomas

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-12 Thread Corinna Vinschen
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


signature.asc
Description: PGP signature


Re: cygpath -w converts relative paths to absolute windows paths

2017-02-11 Thread cyg Simple
On 2/8/2017 5:42 PM, Thomas Wolff wrote:
> Hi Andrey,
> 
> Am 08.02.2017 um 11:54 schrieb Andrey Repin:
>> Greetings, Thomas Wolff!
>>
>>> Am 07.02.2017 um 16:30 schrieb Andrey Repin:
 Greetings, Roger Qiu!

> I've found that `cygpath --windows '../` will give back an absolute
> windows path.
> ...
 ".." is a special path, that can't be safely converted.
>>> How is the special meaning of ".." so much different in Windows than in
>>> Cygwin/Linux/POSIX that it could not be mapped?
>>> Things like dir .., cd .., type ..\sub\file all work comparably.
>> Comparable? May be. Predictable?
>> https://bugs.php.net/bug.php?id=73797
> I don't know what __DIR__ is supposed to mean in PHP. Anyway, handling

It's simply a constant of the directory for the file in which __DIR__
appears.  The constant has a namespace relative to the file.

> ".." is not predictable even within Linux/Cygwin, you could see
> something like:
>> ls dir1/file
> dir1/file
>> cd dir2
>> ls ../dir1/file
> No such file or directory
> 
> (if dir2 is a link), or can have surprising effects of cd vs. cd -P.
> I don't see how that should exclude ".." from being transformed to ".."
> by cygpath -w, even if the result may be somewhat unexpected in some
> border cases (which I haven't seen yet).

I agree.

-- 
cyg Simple

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-08 Thread Roger Qiu

Hi Andrey,

That was probably true in the past, but no longer!

I just tested this: `mklink /D testlink "..\All Users"` in cmd and then 
I went to Cygwin ZSH, and ran `ll`.


This showed me: `testlink -> '../All Users'/`.

Up one directory relative links do work on Windows! This is a directory 
symbolic link, which is superior to directory junctions.


Regardless of directory junction support (which I didn't test), I think 
`cygpath` should give the right results, when I don't specify an 
absolute path, I really mean give me the windows version of the relative 
path.


Now maybe there's some backwards compatibility issues, then perhaps a 
flag that can be set to mean `--really-relative`.


Thanks,

Roger

On 8/02/2017 2:30 AM, Andrey Repin wrote:

Greetings, Roger Qiu!


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.

".." is a special path, that can't be safely converted.
In all cases, using absolute path is preferred for many reasons.


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.

AFAIK, Windows do not support relative junction points.




--
Founder of Polycademy
http://polycademy.com/
+61420925975


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-08 Thread Thomas Wolff

Hi Andrey,

Am 08.02.2017 um 11:54 schrieb Andrey Repin:

Greetings, Thomas Wolff!


Am 07.02.2017 um 16:30 schrieb Andrey Repin:

Greetings, Roger Qiu!


I've found that `cygpath --windows '../` will give back an absolute windows 
path.
...

".." is a special path, that can't be safely converted.

How is the special meaning of ".." so much different in Windows than in
Cygwin/Linux/POSIX that it could not be mapped?
Things like dir .., cd .., type ..\sub\file all work comparably.

Comparable? May be. Predictable?
https://bugs.php.net/bug.php?id=73797
I don't know what __DIR__ is supposed to mean in PHP. Anyway, handling 
".." is not predictable even within Linux/Cygwin, you could see 
something like:

> ls dir1/file
dir1/file
> cd dir2
> ls ../dir1/file
No such file or directory

(if dir2 is a link), or can have surprising effects of cd vs. cd -P.
I don't see how that should exclude ".." from being transformed to ".." 
by cygpath -w, even if the result may be somewhat unexpected in some 
border cases (which I haven't seen yet).

--
Thomas

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-08 Thread Andrey Repin
Greetings, Thomas Wolff!

> Am 07.02.2017 um 16:30 schrieb Andrey Repin:
>> Greetings, Roger Qiu!
>>
>>> I've found that `cygpath --windows '../` will give back an absolute windows 
>>> path.
>>> ...
>> ".." is a special path, that can't be safely converted.
> How is the special meaning of ".." so much different in Windows than in 
> Cygwin/Linux/POSIX that it could not be mapped?
> Things like dir .., cd .., type ..\sub\file all work comparably.

Comparable? May be. Predictable?
https://bugs.php.net/bug.php?id=73797


-- 
With best regards,
Andrey Repin
Wednesday, February 8, 2017 13:53:10

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-07 Thread Brian Inglis
On 2017-02-07 16:34, Thomas Wolff wrote:
> Am 07.02.2017 um 16:30 schrieb Andrey Repin:
>> Greetings, Roger Qiu!
>>> I've found that `cygpath --windows '../` will give back an
>>> absolute windows path.
>>> ...
>> ".." is a special path, that can't be safely converted.
> How is the special meaning of ".." so much different in Windows than
> in Cygwin/Linux/POSIX that it could not be mapped?
> Things like dir .., cd .., type ..\sub\file all work comparably.

Think the problem is tracking logical directory paths following 
symlinks makes it difficult to reconstruct a relative Windows 
directory path - I like and use symlinks a lot as command line 
accessible shortcuts to directories spread all over the place 
- and shells that only track physical directory paths used to 
drive me wild, as cd dir followed by cd .. left me off in the 
wild.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-07 Thread Thomas Wolff

Hi Andrey,

Am 07.02.2017 um 16:30 schrieb Andrey Repin:

Greetings, Roger Qiu!


I've found that `cygpath --windows '../` will give back an absolute windows 
path.
...

".." is a special path, that can't be safely converted.
How is the special meaning of ".." so much different in Windows than in 
Cygwin/Linux/POSIX that it could not be mapped?

Things like dir .., cd .., type ..\sub\file all work comparably.
--
Thomas

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-07 Thread cyg Simple
On 2/7/2017 10:30 AM, Andrey Repin wrote:
> Greetings, Roger Qiu!
> 
>> 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.
> 
> ".." is a special path, that can't be safely converted.
> In all cases, using absolute path is preferred for many reasons.
> 

May be preferred but the -a --absolute flags tell me that it should be a
user choice and not forced on the user.

>> 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.
> 
> AFAIK, Windows do not support relative junction points.
> 
> 

But it should be left to the user of the tools to use them with their
environment as needed.  Getting too cautious to "help" the user with
their own environment isn't ideal because there is always someone else
that the caution hurts.

-- 
cyg Simple

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: cygpath -w converts relative paths to absolute windows paths

2017-02-07 Thread Andrey Repin
Greetings, Roger Qiu!

> 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.

".." is a special path, that can't be safely converted.
In all cases, using absolute path is preferred for many reasons.

> 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.

AFAIK, Windows do not support relative junction points.


-- 
With best regards,
Andrey Repin
Tuesday, February 7, 2017 18:27:52

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



cygpath -w converts relative paths to absolute windows paths

2017-02-06 Thread Roger Qiu

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.


Thanks,

Roger

--
https://github.com/CMCDragonkai
+61420925975


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple