* cygpath -w converts relative paths to absolute windows paths @ 2017-02-07 3:36 Roger Qiu 2017-02-07 15:35 ` Andrey Repin 2017-02-12 11:23 ` Corinna Vinschen 0 siblings, 2 replies; 13+ messages in thread From: Roger Qiu @ 2017-02-07 3:36 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-07 3:36 cygpath -w converts relative paths to absolute windows paths Roger Qiu @ 2017-02-07 15:35 ` Andrey Repin 2017-02-07 23:13 ` cyg Simple ` (2 more replies) 2017-02-12 11:23 ` Corinna Vinschen 1 sibling, 3 replies; 13+ messages in thread From: Andrey Repin @ 2017-02-07 15:35 UTC (permalink / raw) To: Roger Qiu, cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-07 15:35 ` Andrey Repin @ 2017-02-07 23:13 ` cyg Simple 2017-02-07 23:34 ` Thomas Wolff 2017-02-09 1:17 ` Roger Qiu 2 siblings, 0 replies; 13+ messages in thread From: cyg Simple @ 2017-02-07 23:13 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-07 15:35 ` Andrey Repin 2017-02-07 23:13 ` cyg Simple @ 2017-02-07 23:34 ` Thomas Wolff 2017-02-08 1:00 ` Brian Inglis 2017-02-08 11:06 ` Andrey Repin 2017-02-09 1:17 ` Roger Qiu 2 siblings, 2 replies; 13+ messages in thread From: Thomas Wolff @ 2017-02-07 23:34 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-07 23:34 ` Thomas Wolff @ 2017-02-08 1:00 ` Brian Inglis 2017-02-08 11:06 ` Andrey Repin 1 sibling, 0 replies; 13+ messages in thread From: Brian Inglis @ 2017-02-08 1:00 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-07 23:34 ` Thomas Wolff 2017-02-08 1:00 ` Brian Inglis @ 2017-02-08 11:06 ` Andrey Repin 2017-02-08 22:42 ` Thomas Wolff 1 sibling, 1 reply; 13+ messages in thread From: Andrey Repin @ 2017-02-08 11:06 UTC (permalink / raw) To: Thomas Wolff, cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-08 11:06 ` Andrey Repin @ 2017-02-08 22:42 ` Thomas Wolff 2017-02-11 21:27 ` cyg Simple 0 siblings, 1 reply; 13+ messages in thread From: Thomas Wolff @ 2017-02-08 22:42 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-08 22:42 ` Thomas Wolff @ 2017-02-11 21:27 ` cyg Simple 0 siblings, 0 replies; 13+ messages in thread From: cyg Simple @ 2017-02-11 21:27 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-07 15:35 ` Andrey Repin 2017-02-07 23:13 ` cyg Simple 2017-02-07 23:34 ` Thomas Wolff @ 2017-02-09 1:17 ` Roger Qiu 2 siblings, 0 replies; 13+ messages in thread From: Roger Qiu @ 2017-02-09 1:17 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-07 3:36 cygpath -w converts relative paths to absolute windows paths Roger Qiu 2017-02-07 15:35 ` Andrey Repin @ 2017-02-12 11:23 ` Corinna Vinschen 2017-02-12 17:39 ` Thomas Wolff 1 sibling, 1 reply; 13+ messages in thread From: Corinna Vinschen @ 2017-02-12 11:23 UTC (permalink / raw) To: cygwin [-- Attachment #1: Type: text/plain, Size: 1339 bytes --] 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-12 11:23 ` Corinna Vinschen @ 2017-02-12 17:39 ` Thomas Wolff 2017-02-13 15:16 ` Corinna Vinschen 0 siblings, 1 reply; 13+ messages in thread From: Thomas Wolff @ 2017-02-12 17:39 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-12 17:39 ` Thomas Wolff @ 2017-02-13 15:16 ` Corinna Vinschen 2017-02-13 19:34 ` Thomas Wolff 0 siblings, 1 reply; 13+ messages in thread From: Corinna Vinschen @ 2017-02-13 15:16 UTC (permalink / raw) To: cygwin [-- Attachment #1: Type: text/plain, Size: 1745 bytes --] 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: cygpath -w converts relative paths to absolute windows paths 2017-02-13 15:16 ` Corinna Vinschen @ 2017-02-13 19:34 ` Thomas Wolff 0 siblings, 0 replies; 13+ messages in thread From: Thomas Wolff @ 2017-02-13 19:34 UTC (permalink / raw) To: cygwin 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-02-13 19:34 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-02-07 3:36 cygpath -w converts relative paths to absolute windows paths Roger Qiu 2017-02-07 15:35 ` Andrey Repin 2017-02-07 23:13 ` cyg Simple 2017-02-07 23:34 ` Thomas Wolff 2017-02-08 1:00 ` Brian Inglis 2017-02-08 11:06 ` Andrey Repin 2017-02-08 22:42 ` Thomas Wolff 2017-02-11 21:27 ` cyg Simple 2017-02-09 1:17 ` Roger Qiu 2017-02-12 11:23 ` Corinna Vinschen 2017-02-12 17:39 ` Thomas Wolff 2017-02-13 15:16 ` Corinna Vinschen 2017-02-13 19:34 ` Thomas Wolff
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).